diff options
author | 2004-01-12 19:46:08 +0000 | |
---|---|---|
committer | 2004-01-12 19:46:08 +0000 | |
commit | 1a6152b99b2428ef8ad53d0f1b00ab5c7edc0a09 (patch) | |
tree | 67ec2193ad58a65858234aec5156194837ebcaed | |
parent | fix c++ -shared for gcc 3. Here, we recognize -shared and link with (diff) | |
download | wireguard-openbsd-1a6152b99b2428ef8ad53d0f1b00ab5c7edc0a09.tar.xz wireguard-openbsd-1a6152b99b2428ef8ad53d0f1b00ab5c7edc0a09.zip |
- avoid variable sized static array (from millert@)
- check for snprintf overflow
- errx -> err for strdup
commit #1000!
-rw-r--r-- | sbin/swapctl/swapctl.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sbin/swapctl/swapctl.c b/sbin/swapctl/swapctl.c index f330f26f95a..f09fa171089 100644 --- a/sbin/swapctl/swapctl.c +++ b/sbin/swapctl/swapctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: swapctl.c,v 1.12 2003/09/26 16:09:27 deraadt Exp $ */ +/* $OpenBSD: swapctl.c,v 1.13 2004/01/12 19:46:08 avsm Exp $ */ /* $NetBSD: swapctl.c,v 1.9 1998/07/26 20:23:15 mycroft Exp $ */ /* @@ -362,7 +362,7 @@ do_fstab(void) priority = pri; if ((s = strstr(fp->fs_mntops, NFSMNTPT)) != NULL) { - char *t, cmd[strlen(PATH_MOUNT)+1+PATH_MAX+1+PATH_MAX+1]; + char *t, cmd[sizeof(PATH_MOUNT)+PATH_MAX+1+PATH_MAX+1]; /* * Skip this song and dance if we're only @@ -376,7 +376,7 @@ do_fstab(void) *t = '\0'; spec = strdup(s + strlen(NFSMNTPT)); if (spec == NULL) - errx(1, "Out of memory"); + err(1, "strdup"); if (t != 0) *t = ','; @@ -386,8 +386,9 @@ do_fstab(void) free((char *)spec); continue; } - snprintf(cmd, sizeof(cmd), "%s %s %s", - PATH_MOUNT, fp->fs_spec, spec); + if (snprintf(cmd, sizeof(cmd), "%s %s %s", + PATH_MOUNT, fp->fs_spec, spec) >= sizeof(cmd)) + errx(1, "path too long"); if (system(cmd) != 0) { warnx("%s: mount failed", fp->fs_spec); continue; |