From f0477994710c9f7a86ace701aaa8d45e4ee355e9 Mon Sep 17 00:00:00 2001 From: jedgar Date: Sat, 20 Jan 2001 00:29:31 +0000 Subject: Check malloc() and strdup() return values Reviewed by: kris --- libexec/fingerd/fingerd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libexec/fingerd') diff --git a/libexec/fingerd/fingerd.c b/libexec/fingerd/fingerd.c index 15463e8..8524acd 100644 --- a/libexec/fingerd/fingerd.c +++ b/libexec/fingerd/fingerd.c @@ -45,6 +45,7 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ +#include #include #include #include @@ -54,6 +55,7 @@ static const char rcsid[] = #include #include +#include #include #include #include @@ -118,11 +120,13 @@ main(argc, argv) end = memchr(line, 0, sizeof(line)); if (end == NULL) { - t = malloc(sizeof(line) + 1); + if ((t = malloc(sizeof(line) + 1)) == NULL) + logerr("malloc: %s", strerror(errno)); memcpy(t, line, sizeof(line)); t[sizeof(line)] = 0; } else { - t = strdup(line); + if ((t = strdup(line)) == NULL) + logerr("strdup: %s", strerror(errno)); } for (end = t; *end; end++) if (*end == '\n' || *end == '\r') -- cgit v1.1