summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-26 16:09:28 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-26 16:09:28 +0000
commitcfaa13714df367aff51031e23cf7bc52aac393f9 (patch)
tree6d29476735be4553bcee3e8ea6378e2db9e8aa06
parent270598dd720114cfb5f8d54e867679aee352f32e (diff)
check strdup failure; ok anil millert
-rw-r--r--sbin/fsdb/fsdb.c6
-rw-r--r--sbin/mountd/mountd.c4
-rw-r--r--sbin/swapctl/swapctl.c8
-rw-r--r--sbin/sysctl/sysctl.c26
-rw-r--r--usr.sbin/eeprom/main.c4
-rw-r--r--usr.sbin/memconfig/memconfig.c8
-rw-r--r--usr.sbin/wsmoused/wsmoused.c5
7 files changed, 38 insertions, 23 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);
}
/*
diff --git a/usr.sbin/eeprom/main.c b/usr.sbin/eeprom/main.c
index f12893403f5..deb06e9d8a3 100644
--- a/usr.sbin/eeprom/main.c
+++ b/usr.sbin/eeprom/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.10 2002/12/08 16:50:07 millert Exp $ */
+/* $OpenBSD: main.c,v 1.11 2003/09/26 16:09:27 deraadt Exp $ */
/* $NetBSD: main.c,v 1.3 1996/05/16 16:00:55 thorpej Exp $ */
/*-
@@ -239,6 +239,8 @@ action(line)
struct keytabent *ktent;
keyword = strdup(line);
+ if (!keyword)
+ errx(1, "out of memory");
if ((arg = strrchr(keyword, '=')) != NULL)
*arg++ = '\0';
diff --git a/usr.sbin/memconfig/memconfig.c b/usr.sbin/memconfig/memconfig.c
index 92e09bbb47e..134c998df44 100644
--- a/usr.sbin/memconfig/memconfig.c
+++ b/usr.sbin/memconfig/memconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: memconfig.c,v 1.8 2003/06/26 19:47:09 deraadt Exp $ */
+/* $OpenBSD: memconfig.c,v 1.9 2003/09/26 16:09:27 deraadt Exp $ */
/*-
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
@@ -168,7 +168,8 @@ listfunc(memfd, argc, argv)
showall = 1;
break;
case 'o':
- owner = strdup(optarg);
+ if (!(owner = strdup(optarg)))
+ errx(1, "out of memory");
break;
case '?':
default:
@@ -290,7 +291,8 @@ clearfunc(memfd, argc, argv)
case 'o':
if ((*optarg == 0) || (strlen(optarg) > 7))
help("clear");
- owner = strdup(optarg);
+ if (!(owner = strdup(optarg)))
+ errx(1, "out of memory");
break;
case '?':
diff --git a/usr.sbin/wsmoused/wsmoused.c b/usr.sbin/wsmoused/wsmoused.c
index 453c6bc24c3..ae01a593765 100644
--- a/usr.sbin/wsmoused/wsmoused.c
+++ b/usr.sbin/wsmoused/wsmoused.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmoused.c,v 1.14 2003/04/13 11:20:47 jmc Exp $ */
+/* $OpenBSD: wsmoused.c,v 1.15 2003/09/26 16:09:27 deraadt Exp $ */
/*
* Copyright (c) 2001 Jean-Baptiste Marchand, Julien Montagne and Jerome Verdon
@@ -521,7 +521,8 @@ main(int argc, char **argv)
identify = TRUE;
break;
case 'p':
- mouse.portname = strdup(optarg);
+ if ((mouse.portname = strdup(optarg)) == NULL)
+ logerr(1, "out of memory");
break;
case 't':
if (strcmp(optarg, "auto") == 0) {