Skip to content

Commit efd3378

Browse files
committed
Always check the results of getmntopts() and free them.
1 parent df5189a commit efd3378

File tree

22 files changed

+147
-72
lines changed

22 files changed

+147
-72
lines changed

sbin/mount_ados/mount_ados.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: mount_ados.c,v 1.20 2005/09/23 12:10:34 jmmv Exp $ */
1+
/* $NetBSD: mount_ados.c,v 1.21 2006/03/21 21:11:41 christos Exp $ */
22

33
/*
44
* Copyright (c) 1994 Christopher G. Demetriou
@@ -36,7 +36,7 @@
3636

3737
#include <sys/cdefs.h>
3838
#ifndef lint
39-
__RCSID("$NetBSD: mount_ados.c,v 1.20 2005/09/23 12:10:34 jmmv Exp $");
39+
__RCSID("$NetBSD: mount_ados.c,v 1.21 2006/03/21 21:11:41 christos Exp $");
4040
#endif /* not lint */
4141

4242
#include <sys/cdefs.h>
@@ -80,6 +80,7 @@ mount_ados(int argc, char **argv)
8080
{
8181
struct adosfs_args args;
8282
struct stat sb;
83+
mntoptparse_t mp;
8384
int c, mntflags, set_gid, set_uid, set_mask;
8485
char *dev, *dir, canon_dir[MAXPATHLEN], canon_dev[MAXPATHLEN];
8586

@@ -101,7 +102,10 @@ mount_ados(int argc, char **argv)
101102
set_mask = 1;
102103
break;
103104
case 'o':
104-
getmntopts(optarg, mopts, &mntflags, 0);
105+
mp = getmntopts(optarg, mopts, &mntflags, 0);
106+
if (mp == NULL)
107+
err(1, "getmntopts");
108+
freemntopts(mp);
105109
break;
106110
case '?':
107111
default:

sbin/mount_cd9660/mount_cd9660.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: mount_cd9660.c,v 1.21 2005/09/23 12:10:34 jmmv Exp $ */
1+
/* $NetBSD: mount_cd9660.c,v 1.22 2006/03/21 21:11:41 christos Exp $ */
22

33
/*
44
* Copyright (c) 1992, 1993, 1994
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\n\
4646
#if 0
4747
static char sccsid[] = "@(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95";
4848
#else
49-
__RCSID("$NetBSD: mount_cd9660.c,v 1.21 2005/09/23 12:10:34 jmmv Exp $");
49+
__RCSID("$NetBSD: mount_cd9660.c,v 1.22 2006/03/21 21:11:41 christos Exp $");
5050
#endif
5151
#endif /* not lint */
5252

@@ -94,6 +94,7 @@ mount_cd9660(int argc, char **argv)
9494
{
9595
struct iso_args args;
9696
int ch, mntflags, opts;
97+
mntoptparse_t mp;
9798
char *dev, *dir, canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
9899

99100
mntflags = opts = 0;
@@ -115,7 +116,10 @@ mount_cd9660(int argc, char **argv)
115116
opts |= ISOFSMNT_NOJOLIET;
116117
break;
117118
case 'o':
118-
getmntopts(optarg, mopts, &mntflags, &opts);
119+
mp = getmntopts(optarg, mopts, &mntflags, &opts);
120+
if (mp == NULL)
121+
err(1, "getmntopts");
122+
freemntopts(mp);
119123
break;
120124
case 'r':
121125
/* obsolete, retained for compatibility only, use

sbin/mount_ext2fs/mount_ext2fs.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: mount_ext2fs.c,v 1.14 2005/09/23 12:10:34 jmmv Exp $ */
1+
/* $NetBSD: mount_ext2fs.c,v 1.15 2006/03/21 21:11:41 christos Exp $ */
22

33
/*-
44
* Copyright (c) 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993, 1994\n\
3939
#if 0
4040
static char sccsid[] = "@(#)mount_ufs.c 8.4 (Berkeley) 4/26/95";
4141
#else
42-
__RCSID("$NetBSD: mount_ext2fs.c,v 1.14 2005/09/23 12:10:34 jmmv Exp $");
42+
__RCSID("$NetBSD: mount_ext2fs.c,v 1.15 2006/03/21 21:11:41 christos Exp $");
4343
#endif
4444
#endif /* not lint */
4545

@@ -87,13 +87,17 @@ mount_ext2fs(int argc, char *argv[])
8787
int ch, mntflags;
8888
char fs_name[MAXPATHLEN], canon_dev[MAXPATHLEN];
8989
const char *errcause;
90+
mntoptparse_t mp;
9091

9192
mntflags = 0;
9293
optind = optreset = 1; /* Reset for parse of new argv. */
9394
while ((ch = getopt(argc, argv, "o:")) != -1)
9495
switch (ch) {
9596
case 'o':
96-
getmntopts(optarg, mopts, &mntflags, 0);
97+
mp = getmntopts(optarg, mopts, &mntflags, 0);
98+
if (mp == NULL)
99+
err(1, "getmntopts");
100+
freemntopts(mp);
97101
break;
98102
case '?':
99103
default:

sbin/mount_fdesc/mount_fdesc.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: mount_fdesc.c,v 1.16 2005/02/05 14:53:03 xtraeme Exp $ */
1+
/* $NetBSD: mount_fdesc.c,v 1.17 2006/03/21 21:11:41 christos Exp $ */
22

33
/*
44
* Copyright (c) 1992, 1993, 1994
@@ -77,7 +77,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\n\
7777
#if 0
7878
static char sccsid[] = "@(#)mount_fdesc.c 8.3 (Berkeley) 4/26/95";
7979
#else
80-
__RCSID("$NetBSD: mount_fdesc.c,v 1.16 2005/02/05 14:53:03 xtraeme Exp $");
80+
__RCSID("$NetBSD: mount_fdesc.c,v 1.17 2006/03/21 21:11:41 christos Exp $");
8181
#endif
8282
#endif /* not lint */
8383

@@ -114,12 +114,16 @@ mount_fdesc(int argc, char *argv[])
114114
{
115115
int ch, mntflags;
116116
char canon_dir[MAXPATHLEN];
117+
mntoptparse_t mp;
117118

118119
mntflags = 0;
119120
while ((ch = getopt(argc, argv, "o:")) != -1)
120121
switch (ch) {
121122
case 'o':
122-
getmntopts(optarg, mopts, &mntflags, 0);
123+
mp = getmntopts(optarg, mopts, &mntflags, 0);
124+
if (mp == NULL)
125+
err(1, "getmntopts");
126+
freemntopts(mp);
123127
break;
124128
case '?':
125129
default:

sbin/mount_ffs/mount_ffs.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: mount_ffs.c,v 1.18 2005/09/23 12:10:35 jmmv Exp $ */
1+
/* $NetBSD: mount_ffs.c,v 1.19 2006/03/21 21:11:41 christos Exp $ */
22

33
/*-
44
* Copyright (c) 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993, 1994\n\
3939
#if 0
4040
static char sccsid[] = "@(#)mount_ufs.c 8.4 (Berkeley) 4/26/95";
4141
#else
42-
__RCSID("$NetBSD: mount_ffs.c,v 1.18 2005/09/23 12:10:35 jmmv Exp $");
42+
__RCSID("$NetBSD: mount_ffs.c,v 1.19 2006/03/21 21:11:41 christos Exp $");
4343
#endif
4444
#endif /* not lint */
4545

@@ -89,13 +89,17 @@ mount_ffs(int argc, char *argv[])
8989
int ch, mntflags;
9090
char fs_name[MAXPATHLEN], canon_dev[MAXPATHLEN];
9191
const char *errcause;
92+
mntoptparse_t mp;
9293

9394
mntflags = 0;
9495
optind = optreset = 1; /* Reset for parse of new argv. */
9596
while ((ch = getopt(argc, argv, "o:")) != -1)
9697
switch (ch) {
9798
case 'o':
98-
getmntopts(optarg, mopts, &mntflags, 0);
99+
mp = getmntopts(optarg, mopts, &mntflags, 0);
100+
if (mp == NULL)
101+
err(1, "getmntopts");
102+
freemntopts(mp);
99103
break;
100104
case '?':
101105
default:

sbin/mount_filecore/mount_filecore.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: mount_filecore.c,v 1.12 2005/09/23 12:10:35 jmmv Exp $ */
1+
/* $NetBSD: mount_filecore.c,v 1.13 2006/03/21 21:11:41 christos Exp $ */
22

33
/*
44
* Copyright (c) 1992, 1993, 1994 The Regents of the University of California.
@@ -121,6 +121,7 @@ mount_filecore(int argc, char **argv)
121121
struct filecore_args args;
122122
int ch, mntflags, opts, useuid;
123123
char *dev, *dir, canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
124+
mntoptparse_t mp;
124125

125126
mntflags = opts = 0;
126127
useuid = 1;
@@ -150,7 +151,10 @@ mount_filecore(int argc, char **argv)
150151
useuid = 0;
151152
break;
152153
case 'o':
153-
getmntopts(optarg, mopts, &mntflags, 0);
154+
mp = getmntopts(optarg, mopts, &mntflags, 0);
155+
if (mp == NULL)
156+
err(1, "getmntopts");
157+
freemntopts(mp);
154158
break;
155159
case '?':
156160
default:

sbin/mount_kernfs/mount_kernfs.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: mount_kernfs.c,v 1.17 2005/02/05 15:01:09 xtraeme Exp $ */
1+
/* $NetBSD: mount_kernfs.c,v 1.18 2006/03/21 21:11:41 christos Exp $ */
22

33
/*
44
* Copyright (c) 1992, 1993, 1994
@@ -77,7 +77,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\n\
7777
#if 0
7878
static char sccsid[] = "@(#)mount_kernfs.c 8.3 (Berkeley) 5/4/95";
7979
#else
80-
__RCSID("$NetBSD: mount_kernfs.c,v 1.17 2005/02/05 15:01:09 xtraeme Exp $");
80+
__RCSID("$NetBSD: mount_kernfs.c,v 1.18 2006/03/21 21:11:41 christos Exp $");
8181
#endif
8282
#endif /* not lint */
8383

@@ -114,12 +114,16 @@ mount_kernfs(int argc, char *argv[])
114114
{
115115
int ch, mntflags;
116116
char canon_dir[MAXPATHLEN];
117+
mntoptparse_t mp;
117118

118119
mntflags = 0;
119120
while ((ch = getopt(argc, argv, "o:")) != -1)
120121
switch (ch) {
121122
case 'o':
122-
getmntopts(optarg, mopts, &mntflags, 0);
123+
mp = getmntopts(optarg, mopts, &mntflags, 0);
124+
if (mp == NULL)
125+
err(1, "getmntopts");
126+
freemntopts(mp);
123127
break;
124128
case '?':
125129
default:

sbin/mount_lfs/mount_lfs.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: mount_lfs.c,v 1.26 2005/09/23 12:10:35 jmmv Exp $ */
1+
/* $NetBSD: mount_lfs.c,v 1.27 2006/03/21 21:11:41 christos Exp $ */
22

33
/*-
44
* Copyright (c) 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993, 1994\n\
3939
#if 0
4040
static char sccsid[] = "@(#)mount_lfs.c 8.4 (Berkeley) 4/26/95";
4141
#else
42-
__RCSID("$NetBSD: mount_lfs.c,v 1.26 2005/09/23 12:10:35 jmmv Exp $");
42+
__RCSID("$NetBSD: mount_lfs.c,v 1.27 2006/03/21 21:11:41 christos Exp $");
4343
#endif
4444
#endif /* not lint */
4545

@@ -93,6 +93,7 @@ mount_lfs(int argc, char *argv[])
9393
int ch, mntflags, noclean, mntsize, oldflags, i;
9494
char fs_name[MAXPATHLEN], canon_dev[MAXPATHLEN];
9595
char *options;
96+
mntoptparse_t mp;
9697

9798
const char *errcause;
9899
struct statvfs *mntbuf;
@@ -119,7 +120,10 @@ mount_lfs(int argc, char *argv[])
119120
nsegs = optarg;
120121
break;
121122
case 'o':
122-
getmntopts(optarg, mopts, &mntflags, 0);
123+
mp = getmntopts(optarg, mopts, &mntflags, 0);
124+
if (mp == NULL)
125+
err(1, "getmntopts");
126+
freemntopts(mp);
123127
break;
124128
case 's':
125129
short_rds = 1;

sbin/mount_msdos/mount_msdos.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: mount_msdos.c,v 1.37 2005/09/23 12:10:35 jmmv Exp $ */
1+
/* $NetBSD: mount_msdos.c,v 1.38 2006/03/21 21:11:41 christos Exp $ */
22

33
/*
44
* Copyright (c) 1994 Christopher G. Demetriou
@@ -36,7 +36,7 @@
3636

3737
#include <sys/cdefs.h>
3838
#ifndef lint
39-
__RCSID("$NetBSD: mount_msdos.c,v 1.37 2005/09/23 12:10:35 jmmv Exp $");
39+
__RCSID("$NetBSD: mount_msdos.c,v 1.38 2006/03/21 21:11:41 christos Exp $");
4040
#endif /* not lint */
4141

4242
#include <sys/cdefs.h>
@@ -87,6 +87,7 @@ mount_msdos(int argc, char **argv)
8787
char *dev, *dir, canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
8888
time_t now;
8989
struct tm *tm;
90+
mntoptparse_t mp;
9091

9192
mntflags = set_gid = set_uid = set_mask = set_dirmask = set_gmtoff = 0;
9293
(void)memset(&args, '\0', sizeof(args));
@@ -122,7 +123,10 @@ mount_msdos(int argc, char **argv)
122123
set_dirmask = 1;
123124
break;
124125
case 'o':
125-
getmntopts(optarg, mopts, &mntflags, 0);
126+
mp = getmntopts(optarg, mopts, &mntflags, 0);
127+
if (mp == NULL)
128+
err(1, "getmntopts");
129+
freemntopts(mp);
126130
break;
127131
case 't':
128132
args.gmtoff = atoi(optarg);

sbin/mount_nfs/mount_nfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: mount_nfs.c,v 1.48 2005/05/15 21:18:34 dsl Exp $ */
1+
/* $NetBSD: mount_nfs.c,v 1.49 2006/03/21 21:11:41 christos Exp $ */
22

33
/*
44
* Copyright (c) 1992, 1993, 1994
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\n\
4242
#if 0
4343
static char sccsid[] = "@(#)mount_nfs.c 8.11 (Berkeley) 5/4/95";
4444
#else
45-
__RCSID("$NetBSD: mount_nfs.c,v 1.48 2005/05/15 21:18:34 dsl Exp $");
45+
__RCSID("$NetBSD: mount_nfs.c,v 1.49 2006/03/21 21:11:41 christos Exp $");
4646
#endif
4747
#endif /* not lint */
4848

@@ -318,7 +318,7 @@ mount_nfs(int argc, char *argv[])
318318
case 'o':
319319
mp = getmntopts(optarg, mopts, &mntflags, &altflags);
320320
if (mp == NULL)
321-
err(1, NULL);
321+
err(1, "getmntopts");
322322
if (altflags & ALTF_BG)
323323
opflags |= BGRND;
324324
if (altflags & ALTF_CONN)

0 commit comments

Comments
 (0)