summaryrefslogtreecommitdiff
path: root/usr.bin/newsyslog/newsyslog.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-11-27 18:17:39 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-11-27 18:17:39 +0000
commit5db0c87d4bd92aa25db522cb6eb72369609227ab (patch)
tree479e48ec25a738f1ef2b367fbf317b81808295d0 /usr.bin/newsyslog/newsyslog.c
parentdf83932362f058d1dc12ddd627ca13ba1c3e4ad4 (diff)
Fix uninitialized variable introduced in rev 1.40; found by lebel@
If fgets() fails, set err to a reasonable value. Otherwise we could send the signal to pid 0 which would be bad...
Diffstat (limited to 'usr.bin/newsyslog/newsyslog.c')
-rw-r--r--usr.bin/newsyslog/newsyslog.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.bin/newsyslog/newsyslog.c b/usr.bin/newsyslog/newsyslog.c
index 7219a71d6aa..28f2dd574ac 100644
--- a/usr.bin/newsyslog/newsyslog.c
+++ b/usr.bin/newsyslog/newsyslog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: newsyslog.c,v 1.41 2001/11/24 19:53:22 marc Exp $ */
+/* $OpenBSD: newsyslog.c,v 1.42 2001/11/27 18:17:38 millert Exp $ */
/*
* Copyright (c) 1999 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -88,7 +88,7 @@ provided "as is" without express or implied warranty.
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: newsyslog.c,v 1.41 2001/11/24 19:53:22 marc Exp $";
+static char rcsid[] = "$OpenBSD: newsyslog.c,v 1.42 2001/11/27 18:17:38 millert Exp $";
#endif /* not lint */
#ifndef CONF
@@ -329,8 +329,9 @@ send_signal(pidfile, signal)
return;
}
+ errno = 0;
+ err = NULL;
if (fgets(line, sizeof(line), f)) {
- errno = 0;
ulval = strtoul(line, &ep, 10);
if (line[0] == '\0' || (*ep != '\0' && *ep != '\n'))
err = "invalid number in";
@@ -342,6 +343,11 @@ send_signal(pidfile, signal)
err = "preposterous process number in";
else
pid = ulval;
+ } else {
+ if (errno == 0)
+ err = "empty";
+ else
+ err = "error reading";
}
(void)fclose(f);