From 4d5acb37f2fef7b99637885736fbcbb0d762da6a Mon Sep 17 00:00:00 2001
From: jedgar <jedgar@FreeBSD.org>
Date: Sat, 20 Jan 2001 01:22:31 +0000
Subject: Check strdup() return values

Reviewed by:	kris
---
 usr.sbin/apmd/apmd.c            |  3 ++-
 usr.sbin/apmd/contrib/pccardq.c | 15 ++++++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c
index 2ebd5572..470bcc6 100644
--- a/usr.sbin/apmd/apmd.c
+++ b/usr.sbin/apmd/apmd.c
@@ -139,7 +139,8 @@ event_cmd_exec_clone(void *this)
 	newone->evcmd.len = oldone->evcmd.len;
 	newone->evcmd.name = oldone->evcmd.name;
 	newone->evcmd.op = oldone->evcmd.op;
-	newone->line = strdup(oldone->line);
+	if ((newone->line = strdup(oldone->line)) == NULL)
+		err(1, "out of memory");
 	return (struct event_cmd *) newone;
 }
 void
diff --git a/usr.sbin/apmd/contrib/pccardq.c b/usr.sbin/apmd/contrib/pccardq.c
index 20b789d..2bace22 100644
--- a/usr.sbin/apmd/contrib/pccardq.c
+++ b/usr.sbin/apmd/contrib/pccardq.c
@@ -194,9 +194,18 @@ get_slot_info(int so, int slot, char **manuf, char **version, char
     if (s != NULL && strchr(s, '~') != NULL)
 	goto parse_err;
 
-    *manuf = strdup(_manuf);
-    *version = strdup(_version);
-    *device = strdup(_device);
+    if ((*manuf = strdup(_manuf)) == NULL) {
+	warn("strdup");
+	goto err;
+    }
+    if ((*version = strdup(_version)) == NULL) {
+	warn("strdup");
+	goto err;
+    }
+    if ((*device = strdup(_device)) == NULL) {
+	warn("strdup");
+	goto err;
+    }
     if (*manuf == NULL || *version == NULL || *device == NULL) {
 	warn("strdup");
 	goto err;
-- 
cgit v1.1