diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-09-26 16:09:28 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-09-26 16:09:28 +0000 |
commit | cfaa13714df367aff51031e23cf7bc52aac393f9 (patch) | |
tree | 6d29476735be4553bcee3e8ea6378e2db9e8aa06 /sbin | |
parent | 270598dd720114cfb5f8d54e867679aee352f32e (diff) |
check strdup failure; ok anil millert
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsdb/fsdb.c | 6 | ||||
-rw-r--r-- | sbin/mountd/mountd.c | 4 | ||||
-rw-r--r-- | sbin/swapctl/swapctl.c | 8 | ||||
-rw-r--r-- | sbin/sysctl/sysctl.c | 26 |
4 files changed, 27 insertions, 17 deletions
diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c index 3a8bff77efe..0cb330839f7 100644 --- a/sbin/fsdb/fsdb.c +++ b/sbin/fsdb/fsdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsdb.c,v 1.15 2003/08/25 23:28:15 tedu Exp $ */ +/* $OpenBSD: fsdb.c,v 1.16 2003/09/26 16:09:27 deraadt Exp $ */ /* $NetBSD: fsdb.c,v 1.7 1997/01/11 06:50:53 lukem Exp $ */ /*- @@ -38,7 +38,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: fsdb.c,v 1.15 2003/08/25 23:28:15 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: fsdb.c,v 1.16 2003/09/26 16:09:27 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -250,6 +250,8 @@ cmdloop(void) history(hist, H_ENTER, elline); line = strdup(elline); + if (line == NULL) + errx(1, "out of memory"); cmd_argv = crack(line, &cmd_argc); if (cmd_argc) { /* diff --git a/sbin/mountd/mountd.c b/sbin/mountd/mountd.c index f17bd0b6d6b..c5ee03a41a6 100644 --- a/sbin/mountd/mountd.c +++ b/sbin/mountd/mountd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mountd.c,v 1.59 2003/06/11 06:22:14 deraadt Exp $ */ +/* $OpenBSD: mountd.c,v 1.60 2003/09/26 16:09:27 deraadt Exp $ */ /* $NetBSD: mountd.c,v 1.31 1996/02/18 11:57:53 fvdl Exp $ */ /* @@ -939,6 +939,8 @@ get_exportlist(void) if (hpe == NULL) out_of_mem(); hpe->h_name = strdup("Default"); + if (hpe->h_name == NULL); + out_of_mem(); hpe->h_addrtype = AF_INET; hpe->h_length = sizeof (u_int32_t); hpe->h_addr_list = NULL; diff --git a/sbin/swapctl/swapctl.c b/sbin/swapctl/swapctl.c index 486bbe11678..f330f26f95a 100644 --- a/sbin/swapctl/swapctl.c +++ b/sbin/swapctl/swapctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: swapctl.c,v 1.11 2003/03/03 13:41:23 miod Exp $ */ +/* $OpenBSD: swapctl.c,v 1.12 2003/09/26 16:09:27 deraadt Exp $ */ /* $NetBSD: swapctl.c,v 1.9 1998/07/26 20:23:15 mycroft Exp $ */ /* @@ -375,12 +375,12 @@ do_fstab(void) if (t != 0) *t = '\0'; spec = strdup(s + strlen(NFSMNTPT)); - if (t != 0) - *t = ','; - if (spec == NULL) errx(1, "Out of memory"); + if (t != 0) + *t = ','; + if (strlen(spec) == 0) { warnx("empty mountpoint"); free((char *)spec); diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 9af8107b4b2..323479f5d9d 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.98 2003/09/09 11:55:05 jmc Exp $ */ +/* $OpenBSD: sysctl.c,v 1.99 2003/09/26 16:09:27 deraadt Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -40,7 +40,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)sysctl.c 8.5 (Berkeley) 5/9/95"; #else -static char *rcsid = "$OpenBSD: sysctl.c,v 1.98 2003/09/09 11:55:05 jmc Exp $"; +static char *rcsid = "$OpenBSD: sysctl.c,v 1.99 2003/09/26 16:09:27 deraadt Exp $"; #endif #endif /* not lint */ @@ -1970,7 +1970,7 @@ sysctl_sensors(char *string, char **bufpp, int mib[], int flags, int *typep) char **emul_names; int emul_num, nemuls; -void emul_init(void); +int emul_init(void); int sysctl_emul(char *string, char *newval, int flags) @@ -1979,7 +1979,10 @@ sysctl_emul(char *string, char *newval, int flags) char *head, *target; size_t len; - emul_init(); + if (emul_init() == -1) { + warnx("emul_init: out of memory"); + return (1); + } mib[0] = CTL_KERN; mib[1] = KERN_EMUL; @@ -2072,7 +2075,7 @@ sysctl_emul(char *string, char *newval, int flags) } -void +int emul_init(void) { static int done; @@ -2089,13 +2092,11 @@ emul_init(void) mib[2] = KERN_EMUL_NUM; len = sizeof(int); if (sysctl(mib, 3, &emul_num, &len, NULL, 0) == -1) - return; + return (-1); emul_names = calloc(emul_num, sizeof(char *)); - if (emul_names == NULL) { - warn("emul_init"); - return; - } + if (emul_names == NULL) + return (-1); nemuls = emul_num; for (i = 0; i < emul_num; i++) { @@ -2110,7 +2111,12 @@ emul_init(void) continue; } emul_names[i] = strdup(string); + if (emul_names[i] == NULL) { + free(emul_names); + return (-1); + } } + return (0); } /* |