Skip site navigation (1)Skip section navigation (2)
Date:      08 Sep 2002 23:51:08 +0930
From:      "Daniel O'Connor" <doconnor@gsoft.com.au>
To:        Peter Wemm <peter@FreeBSD.ORG>
Cc:        cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG
Subject:   Re: cvs commit: src/sbin/mount_nfs mount_nfs.c
Message-ID:  <1031494869.1246.33.camel@chowder.dons.net.au>
In-Reply-To: <200209061959.g86JxTS9019217@freefall.freebsd.org>
References:  <200209061959.g86JxTS9019217@freefall.freebsd.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On Sat, 2002-09-07 at 05:29, Peter Wemm wrote: 
>   Bandaid for mount_nfs segfaulting with the more obscure mount options
>   in /etc/fstab.  This isn't a real fix though and I'm still not sure
>   why it started failing.  mount(8) breaks up the nfs args into seperate
>   repeated '-o option=value' arguments.  But, the altflags variable that
>   we use to track things is incrementally built up each time we see the
>   next option and shows us the cumulative set of flags, not just the
>   flag that we are currently looking at.  As a result, the strstr hack
>   for looking up flags in a giant -o opt=val,opt=val, etc string was failing
>   and causing a segfault.  I do not know what changed recently that caused
>   this to suddenly break, but the code has been rather bogus for some time.

Hah, well I'm glad it wasn't just me...

Any chance of MFC'ing this change?

You left a debugging statement in too (See first part of the diff), and
made some gratuitous tab/space changes.

I've attached a diff for stable.

Interestingly this still crashes ->
/sbin/mount -onodev,soft,intr,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0 127.0.0.1:foo /usr/home/darius/abc
But this doesn't ->
/sbin/mount_nfs -onodev,soft,intr,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0 127.0.0.1:foo /usr/home/darius/abc

In the former case mount_nfs crashes.. I can't see how that is possible
though :(

-- 
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 9A8C 569F 685A D928 5140  AE4B 319B 41F4 5D17 FDD5

[-- Attachment #2 --]
===================================================================
RCS file: /home/ncvs/src/sbin/mount_nfs/mount_nfs.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -p -r1.55 -r1.56
--- src/sbin/mount_nfs/mount_nfs.c	2002/08/26 13:08:23	1.55
+++ src/sbin/mount_nfs/mount_nfs.c	2002/09/06 19:59:29	1.56
@@ -45,7 +45,7 @@ static const char copyright[] =
 static char sccsid[] = "@(#)mount_nfs.c	8.11 (Berkeley) 5/4/95";
 #endif
 static const char rcsid[] =
-  "$FreeBSD: /home/ncvs/src/sbin/mount_nfs/mount_nfs.c,v 1.55 2002/08/26 13:08:23 iedowse Exp $";
+  "$FreeBSD: /home/ncvs/src/sbin/mount_nfs/mount_nfs.c,v 1.56 2002/09/06 19:59:29 peter Exp $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -326,46 +326,58 @@ main(argc, argv)
 				altflags |= ALTF_NFSV3;
 			getmntopts(optarg, mopts, &mntflags, &altflags);
 			set_flags(&altflags, &nfsargsp->flags, FALSE);
+printf("altflags= %x, optarg = %s\n", altflags, optarg);
 			/*
 			 * Handle altflags which don't map directly to
 			 * mount flags.
 			 */
-			if(altflags & ALTF_BG)
+			if (altflags & ALTF_BG)
 				opflags |= BGRND;
-			if(altflags & ALTF_MNTUDP)
+			if (altflags & ALTF_MNTUDP)
 				mnttcp_ok = 0;
-			if(altflags & ALTF_TCP) {
+			if (altflags & ALTF_TCP) {
 				nfsargsp->sotype = SOCK_STREAM;
 				nfsproto = IPPROTO_TCP;
 			}
-			if(altflags & ALTF_PORT) {
+			if (altflags & ALTF_PORT) {
 				/*
 				 * XXX Converting from a string to an int
 				 * and back again is silly, and we should
 				 * allow /etc/services names.
 				 */
-				asprintf(&portspec, "%d",
-				    atoi(strstr(optarg, "port=") + 5));
-				if (portspec == NULL)
-					err(1, "asprintf");
+				p = strstr(optarg, "port=");
+				if (p) {
+					asprintf(&portspec, "%d",
+					    atoi(p + 5));
+					if (portspec == NULL)
+						err(1, "asprintf");
+				}
 			}
 			mountmode = ANY;
-			if(altflags & ALTF_NFSV2)
+			if (altflags & ALTF_NFSV2)
 				mountmode = V2;
-			if(altflags & ALTF_NFSV3)
+			if (altflags & ALTF_NFSV3)
 				mountmode = V3;
-			if(altflags & ALTF_ACREGMIN)
-				nfsargsp->acregmin = atoi(strstr(optarg,
-				    "acregmin=") + 9);
-			if(altflags & ALTF_ACREGMAX)
-				nfsargsp->acregmax = atoi(strstr(optarg,
-				    "acregmax=") + 9);
-			if(altflags & ALTF_ACDIRMIN)
-				nfsargsp->acdirmin = atoi(strstr(optarg,
-				    "acdirmin=") + 9);
-			if(altflags & ALTF_ACDIRMAX)
-				nfsargsp->acdirmax = atoi(strstr(optarg,
-				    "acdirmax=") + 9);
+			if (altflags & ALTF_ACREGMIN) {
+				p = strstr(optarg, "acregmin=");
+				if (p)
+					nfsargsp->acregmin = atoi(p + 9);
+			}
+			if (altflags & ALTF_ACREGMAX) {
+				p = strstr(optarg, "acregmax=");
+				if (p)
+					nfsargsp->acregmax = atoi(p + 9);
+			}
+			if (altflags & ALTF_ACDIRMIN) {
+				p = strstr(optarg, "acdirmin=");
+				if (p)
+					nfsargsp->acdirmin = atoi(p + 9);
+			}
+			if (altflags & ALTF_ACDIRMAX) {
+				p = strstr(optarg, "acdirmax=");
+				if (p)
+					nfsargsp->acdirmax = atoi(p + 9);
+			}
 			break;
 		case 'P':
 			/* obsolete for NFSMNT_RESVPORT, now default */
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1031494869.1246.33.camel>