about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-04-05 17:13:54 +0200
committerDuncaen <mail@duncano.de>2018-06-20 18:02:46 +0200
commit42ad2206322dece60094974eb3389e6816229111 (patch)
treef2f3ea5f8a08510e7897176dede89b95b2739f9c
parentffa76819288ae458b10adb7b5bafc5855508b8be (diff)
downloadrunit-void-42ad2206322dece60094974eb3389e6816229111.tar.gz
runit-void-42ad2206322dece60094974eb3389e6816229111.tar.xz
runit-void-42ad2206322dece60094974eb3389e6816229111.zip
vlogger: strdup error check
-rw-r--r--vlogger.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/vlogger.c b/vlogger.c
index 4932408..32a8ddb 100644
--- a/vlogger.c
+++ b/vlogger.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -49,8 +50,6 @@ CODE facilitynames[] = {
 	{ 0, -1 }
 };
 
-static char *tag;
-
 static void
 strpriority(char *s, int *facility, int *level)
 {
@@ -74,7 +73,7 @@ strpriority(char *s, int *facility, int *level)
 int
 main(int argc, char *argv[])
 {
-	char c, *p, *argv0;
+	char c, *p, *argv0, *tag;
 	int facility = LOG_DAEMON;
 	int level = LOG_INFO;
 
@@ -83,7 +82,10 @@ main(int argc, char *argv[])
 	if (((p = strrchr(*argv, '/')) && !strncmp(p+1, "run", 3)) &&
 	    (*p = 0, (p = strrchr(*argv, '/')) && !strncmp(p+1, "log", 3)) &&
 	    (*p = 0, (p = strrchr(*argv, '/'))) != 0) {
-		tag = strdup(p+1);
+		if (!(tag = strdup(p+1))) {
+			fprintf(stderr, "vlogger: strdup: %s\n", strerror(errno));
+			exit(1);
+		}
 	}
 
 	while ((c = getopt(argc, argv, "p:t:")) != -1)