diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-12-12 19:02:51 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-12-12 19:02:51 +0000 |
commit | fb3d03988d5a2c5038d4d129d2ce2ef8a2ecd9e5 (patch) | |
tree | 37aa661d93433a82ec6d978b99df1e8b918ea458 | |
parent | bb4e568406020ba0118e11ed2dc9905ad87cb442 (diff) |
o pids should be pid_t, not int
o check return value of fscanf()
-rw-r--r-- | usr.sbin/cron/misc.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/usr.sbin/cron/misc.c b/usr.sbin/cron/misc.c index fab3335493b..3362f812a4a 100644 --- a/usr.sbin/cron/misc.c +++ b/usr.sbin/cron/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.10 2001/02/20 02:03:19 millert Exp $ */ +/* $OpenBSD: misc.c,v 1.11 2001/12/12 19:02:50 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved */ @@ -21,7 +21,7 @@ */ #if !defined(lint) && !defined(LINT) -static char rcsid[] = "$OpenBSD: misc.c,v 1.10 2001/02/20 02:03:19 millert Exp $"; +static char rcsid[] = "$OpenBSD: misc.c,v 1.11 2001/12/12 19:02:50 millert Exp $"; #endif /* vix 26jan87 [RCS has the rest of the log] @@ -290,7 +290,8 @@ acquire_daemonlock(closeflag) static FILE *fp = NULL; char buf[3*MAX_FNAME]; char pidfile[MAX_FNAME]; - int fd, otherpid; + int fd; + PID_T otherpid; if (closeflag && fp) { fclose(fp); @@ -318,10 +319,14 @@ acquire_daemonlock(closeflag) if (flock(fd, LOCK_EX|LOCK_NB) < OK) { int save_errno = errno; - fscanf(fp, "%d", &otherpid); - snprintf(buf, sizeof buf, - "can't lock %s, otherpid may be %d: %s", - pidfile, otherpid, strerror(save_errno)); + if (fscanf(fp, "%d", &otherpid) == 1) + snprintf(buf, sizeof buf, + "can't lock %s, otherpid may be %d: %s", + pidfile, otherpid, strerror(save_errno)); + else + snprintf(buf, sizeof buf, + "can't lock %s, otherpid unknown: %s", + pidfile, strerror(save_errno)); fprintf(stderr, "%s: %s\n", ProgramName, buf); log_it("CRON", getpid(), "DEATH", buf); exit(ERROR_EXIT); |