summaryrefslogtreecommitdiff
path: root/usr.bin/newsyslog
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-06-09 20:29:11 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-06-09 20:29:11 +0000
commit0af78c6624e8b27150759b393d769a58aa3eb5db (patch)
tree107f5fc2af319606a0ad51a03e8e46def8553c69 /usr.bin/newsyslog
parent129e7d9d3c7ec29d267246307ae8198e210fb70e (diff)
Use strtol() not strtoul() so we can detect a negative number in a pid file.
Diffstat (limited to 'usr.bin/newsyslog')
-rw-r--r--usr.bin/newsyslog/newsyslog.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.bin/newsyslog/newsyslog.c b/usr.bin/newsyslog/newsyslog.c
index a0e63ddc3e9..9fe44388084 100644
--- a/usr.bin/newsyslog/newsyslog.c
+++ b/usr.bin/newsyslog/newsyslog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: newsyslog.c,v 1.68 2003/06/09 20:21:36 millert Exp $ */
+/* $OpenBSD: newsyslog.c,v 1.69 2003/06/09 20:29:10 millert Exp $ */
/*
* Copyright (c) 1999, 2002, 2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -68,7 +68,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: newsyslog.c,v 1.68 2003/06/09 20:21:36 millert Exp $";
+static const char rcsid[] = "$OpenBSD: newsyslog.c,v 1.69 2003/06/09 20:29:10 millert Exp $";
#endif /* not lint */
#ifndef CONF
@@ -364,7 +364,7 @@ send_signal(char *pidfile, int signal)
pid_t pid;
FILE *f;
char line[BUFSIZ], *ep, *err;
- unsigned long ulval;
+ long lval;
if ((f = fopen(pidfile, "r")) == NULL) {
warn("can't open %s", pidfile);
@@ -375,17 +375,17 @@ send_signal(char *pidfile, int signal)
errno = 0;
err = NULL;
if (fgets(line, sizeof(line), f)) {
- ulval = strtoul(line, &ep, 10);
+ lval = strtol(line, &ep, 10);
if (line[0] == '\0' || (*ep != '\0' && *ep != '\n'))
err = "invalid number in";
- else if (errno == ERANGE && ulval == ULONG_MAX)
+ else if (lval < 0 || (errno == ERANGE && lval == LONG_MAX))
err = "out of range number in";
- else if (ulval == 0)
+ else if (lval == 0)
err = "no number in";
- else if (ulval < MIN_PID)
+ else if (lval < MIN_PID)
err = "preposterous process number in";
else
- pid = ulval;
+ pid = (pid_t)lval;
} else {
if (errno == 0)
err = "empty";