Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/nfs nfsrv_mknod: reject device numbers which we can't ha...
details: https://anonhg.NetBSD.org/src/rev/0de947637f7a
branches: trunk
changeset: 580977:0de947637f7a
user: yamt <yamt%NetBSD.org@localhost>
date: Wed May 18 12:57:34 2005 +0000
description:
nfsrv_mknod: reject device numbers which we can't handle.
diffstat:
sys/nfs/nfs_serv.c | 52 +++++++++++++++++++++++++++-------------------------
1 files changed, 27 insertions(+), 25 deletions(-)
diffs (80 lines):
diff -r a6e50f0fd3c6 -r 0de947637f7a sys/nfs/nfs_serv.c
--- a/sys/nfs/nfs_serv.c Wed May 18 11:26:11 2005 +0000
+++ b/sys/nfs/nfs_serv.c Wed May 18 12:57:34 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_serv.c,v 1.94 2005/02/26 22:39:50 perry Exp $ */
+/* $NetBSD: nfs_serv.c,v 1.95 2005/05/18 12:57:34 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.94 2005/02/26 22:39:50 perry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.95 2005/05/18 12:57:34 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1648,6 +1648,31 @@
vtyp = nfsv3tov_type(*tl);
if (vtyp != VCHR && vtyp != VBLK && vtyp != VSOCK && vtyp != VFIFO) {
error = NFSERR_BADTYPE;
+ goto abort;
+ }
+ VATTR_NULL(&va);
+ va.va_mode = 0;
+ nfsm_srvsattr(&va);
+ if (vtyp == VCHR || vtyp == VBLK) {
+ dev_t rdev;
+
+ nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
+ major = fxdr_unsigned(u_int32_t, *tl++);
+ minor = fxdr_unsigned(u_int32_t, *tl);
+ rdev = makedev(major, minor);
+ if (major(rdev) != major || minor(rdev) != minor) {
+ error = EINVAL;
+ goto abort;
+ }
+ va.va_rdev = rdev;
+ }
+
+ /*
+ * Iff doesn't exist, create it.
+ */
+ if (nd.ni_vp) {
+ error = EEXIST;
+abort:
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
if (nd.ni_dvp == nd.ni_vp)
vrele(nd.ni_dvp);
@@ -1657,29 +1682,6 @@
vput(nd.ni_vp);
goto out;
}
- VATTR_NULL(&va);
- va.va_mode = 0;
- nfsm_srvsattr(&va);
- if (vtyp == VCHR || vtyp == VBLK) {
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- major = fxdr_unsigned(u_int32_t, *tl++);
- minor = fxdr_unsigned(u_int32_t, *tl);
- va.va_rdev = makedev(major, minor);
- }
-
- /*
- * Iff doesn't exist, create it.
- */
- if (nd.ni_vp) {
- error = EEXIST;
- VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- vput(nd.ni_vp);
- goto out;
- }
va.va_type = vtyp;
if (vtyp == VSOCK) {
nqsrv_getl(nd.ni_dvp, ND_WRITE);
Home |
Main Index |
Thread Index |
Old Index