bin/61666: mount_nfs parsing bug, segmentation fault
Volker Stolz
stolz at i2.informatik.rwth-aachen.de
Wed Feb 18 03:50:26 PST 2004
The following reply was made to PR bin/61666; it has been noted by GNATS.
From: Volker Stolz <stolz at i2.informatik.rwth-aachen.de>
To: freebsd-gnats-submit at FreeBSD.org, j at pureftpd.org
Cc:
Subject: Re: bin/61666: mount_nfs parsing bug, segmentation fault
Date: Wed, 18 Feb 2004 12:48:38 +0100
--cWoXeonUoKmBZSoM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
The attached patch *should* help, but probably needs careful review.
The option handling is mind-boggling anyway, especially w.r.t.
'mountmode'. As 'getmntopts' and 'set_flags' are side-effect free,
I'm confident it does the Right Thing. Patched and tested against
-STABLE.
Cheers,
Volker
--
http://www-i2.informatik.rwth-aachen.de/stolz/ *** PGP *** S/MIME
rage against the finite state machine
--cWoXeonUoKmBZSoM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=mount_nfs
--- mount_nfs/mount_nfs.c Tue Aug 5 10:56:03 2003
+++ vs.mount_nfs/mount_nfs.c Wed Feb 18 12:12:46 2004
@@ -259,7 +259,7 @@
register struct nfs_args *nfsargsp;
struct nfs_args nfsargs;
struct nfsd_cargs ncd;
- int mntflags, altflags, nfssvc_flag, num;
+ int mntflags, altflags, curflags, nfssvc_flag, num;
char *name, *p, *spec;
char mntpath[MAXPATHLEN];
struct vfsconf vfc;
@@ -355,43 +355,47 @@
nfsargsp->flags &= ~NFSMNT_RESVPORT;
break;
case 'o':
- altflags = 0;
+ altflags = curflags = 0;
+ /* Get flags in current -o */
+ getmntopts(optarg, mopts, &mntflags, &curflags);
set_flags(&altflags, &nfsargsp->flags, TRUE);
+ /* NetBSD handles conflicting mountmodes much nicer */
if (mountmode == V2)
- altflags |= ALTF_NFSV2;
+ curflags |= ALTF_NFSV2;
else if (mountmode == V3)
- altflags |= ALTF_NFSV3;
- getmntopts(optarg, mopts, &mntflags, &altflags);
+ curflags |= ALTF_NFSV3;
+ /* Join old and new flags */
+ altflags = altflags | curflags;
set_flags(&altflags, &nfsargsp->flags, FALSE);
/*
- * Handle altflags which don't map directly to
+ * Handle curflags which don't map directly to
* mount flags.
*/
- if(altflags & ALTF_BG)
+ if(curflags & ALTF_BG)
opflags |= BGRND;
- if(altflags & ALTF_MNTUDP)
+ if(curflags & ALTF_MNTUDP)
mnttcp_ok = 0;
- if(altflags & ALTF_TCP) {
+ if(curflags & ALTF_TCP) {
nfsargsp->sotype = SOCK_STREAM;
nfsproto = IPPROTO_TCP;
}
- if(altflags & ALTF_PORT)
+ if(curflags & ALTF_PORT)
port_no = atoi(strstr(optarg, "port=") + 5);
mountmode = ANY;
- if(altflags & ALTF_NFSV2)
+ if(curflags & ALTF_NFSV2)
mountmode = V2;
- if(altflags & ALTF_NFSV3)
+ if(curflags & ALTF_NFSV3)
mountmode = V3;
- if(altflags & ALTF_ACREGMIN)
+ if(curflags & ALTF_ACREGMIN)
nfsargsp->acregmin = atoi(strstr(optarg,
"acregmin=") + 9);
- if(altflags & ALTF_ACREGMAX)
+ if(curflags & ALTF_ACREGMAX)
nfsargsp->acregmax = atoi(strstr(optarg,
"acregmax=") + 9);
- if(altflags & ALTF_ACDIRMIN)
+ if(curflags & ALTF_ACDIRMIN)
nfsargsp->acdirmin = atoi(strstr(optarg,
"acdirmin=") + 9);
- if(altflags & ALTF_ACDIRMAX)
+ if(curflags & ALTF_ACDIRMAX)
nfsargsp->acdirmax = atoi(strstr(optarg,
"acdirmax=") + 9);
break;
--cWoXeonUoKmBZSoM--
More information about the freebsd-bugs
mailing list