about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristopher Brannon <chris@the-brannons.com>2018-06-21 21:22:19 -0700
committerDuncaen <mail@duncano.de>2018-06-22 14:39:42 +0200
commita2320e50b375576fbe0e72636c4900bcc4704b80 (patch)
treed35ae46e2006c0d9839f435c9b76e62186173e29
parent88697d7fbf3a11969bdbaa39e22adbb38d2e72f4 (diff)
downloadrunit-void-a2320e50b375576fbe0e72636c4900bcc4704b80.tar.gz
runit-void-a2320e50b375576fbe0e72636c4900bcc4704b80.tar.xz
runit-void-a2320e50b375576fbe0e72636c4900bcc4704b80.zip
vlogger: a couple of bugfixes.
* Don't store the return value of getopt in a char.  Storing in a char
  and comparing against -1 breaks on ARM, where char is unsigned.
* The line argument to getline should point at a NULL char *.  Otherwise,
  getline will treat *line as a pointer to an allocated buffer.  With
  a little extra work, we could reuse the buffer, but always calling getline
  with *line == NULL is safe.

Closes: #2 [via git-merge-pr]
-rw-r--r--vlogger.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/vlogger.c b/vlogger.c
index cd32143..debad36 100644
--- a/vlogger.c
+++ b/vlogger.c
@@ -76,8 +76,9 @@ strpriority(char *s, int *facility, int *level)
 int
 main(int argc, char *argv[])
 {
-	char c, *p, *argv0;
+	char *p, *argv0;
 	char *tag = NULL;
+	int c;
 	int facility = LOG_DAEMON;
 	int level = LOG_INFO;
 
@@ -116,7 +117,7 @@ usage:
 
 	openlog(tag, 0, facility);
 
-	char *line;
+	char *line = NULL;
 	size_t linelen = 0;
 	ssize_t rd;
 	while ((rd = getline(&line, &linelen, stdin)) != -1) {