(patch) strdup(3) and getmntinfo(3) failure tests in mount(8)
Index: mount.c
RCS file: /cvs/src/sbin/mount/mount.c,v
retrieving revision 1.29
diff -u -r1.29 mount.c
--- mount.c 2002/11/06 14:14:48 1.29
+++ mount.c 2003/01/19 03:53:11
@@ -308,7 +308,8 @@
if (mntopts == NULL)
return (0);
- optbuf = strdup(mntopts);
+ if ((optbuf = strdup(mntopts)) == NULL)
+ err(1, "strdup");
found = 0;
for (opt = optbuf; !found && opt != NULL; strsep(&opt, ","))
found = !strncmp(opt, option, strlen(option));
@@ -593,7 +594,8 @@
struct statfs *mntbuf;
int i, mntsize;
- mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
+ if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
+ err(1, "getmntinfo");
for (i = 0; i < mntsize; i++)
if (strcmp(mntbuf[i].f_mntfromname, name) == 0 ||
strcmp(mntbuf[i].f_mntonname, name) == 0)
@@ -664,8 +666,10 @@
if ((cp = malloc(i)) == NULL)
err(1, NULL);
(void)snprintf(cp, i, "%s,%s", s0, s1);
- } else
- cp = strdup(s1);
+ } else {
+ if ((cp = strdup(s1)) == NULL)
+ err(1, "strdup");
if (s0)
free(s0);
Received on Sat Jan 18 23:02:54 2003
This archive was generated by hypermail 2.1.8
: Wed Aug 23 2006 - 13:29:48 EDT
|