Skip to content

Commit a2320e5

Browse files
CMBDuncaen
authored andcommitted
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]
1 parent 88697d7 commit a2320e5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

vlogger.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ strpriority(char *s, int *facility, int *level)
7676
int
7777
main(int argc, char *argv[])
7878
{
79-
char c, *p, *argv0;
79+
char *p, *argv0;
8080
char *tag = NULL;
81+
int c;
8182
int facility = LOG_DAEMON;
8283
int level = LOG_INFO;
8384

@@ -116,7 +117,7 @@ main(int argc, char *argv[])
116117

117118
openlog(tag, 0, facility);
118119

119-
char *line;
120+
char *line = NULL;
120121
size_t linelen = 0;
121122
ssize_t rd;
122123
while ((rd = getline(&line, &linelen, stdin)) != -1) {

0 commit comments

Comments
 (0)