summaryrefslogtreecommitdiffstats
path: root/sbin/mount_nfs
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2002-09-06 19:59:29 +0000
committerpeter <peter@FreeBSD.org>2002-09-06 19:59:29 +0000
commit1ec96b6cd8977d3142ed0f2b51bcea9b0a890157 (patch)
tree50e8cd6fbc269ce95d971a72d2f7fd7520116923 /sbin/mount_nfs
parent5419354c9fc7ce9e7f3f8f8c77527836b83b3d93 (diff)
downloadFreeBSD-src-1ec96b6cd8977d3142ed0f2b51bcea9b0a890157.zip
FreeBSD-src-1ec96b6cd8977d3142ed0f2b51bcea9b0a890157.tar.gz
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.
Diffstat (limited to 'sbin/mount_nfs')
-rw-r--r--sbin/mount_nfs/mount_nfs.c56
1 files changed, 34 insertions, 22 deletions
diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c
index 349b912..f1772de 100644
--- a/sbin/mount_nfs/mount_nfs.c
+++ b/sbin/mount_nfs/mount_nfs.c
@@ -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 */
OpenPOWER on IntegriCloud