diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2004-07-22 16:36:29 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2004-07-22 16:36:29 +0000 |
commit | e54998b0b87b03285b22cb2a5b07329d8d82917e (patch) | |
tree | 1c259cb1c54578d95fea14300d9240e25542c67b /usr.sbin/cron | |
parent | e0f82dff79248e9f8a38b398ace5ba24a441df57 (diff) |
Fix incorrect snprintf return value check noticed by Jarno Huuskonen.
Also make a utime() failure non-fatal since the important thing is
the poke on the socket now.
Diffstat (limited to 'usr.sbin/cron')
-rw-r--r-- | usr.sbin/cron/misc.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/usr.sbin/cron/misc.c b/usr.sbin/cron/misc.c index 802541ddf5e..1b895cc3760 100644 --- a/usr.sbin/cron/misc.c +++ b/usr.sbin/cron/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.32 2004/07/09 16:22:02 deraadt Exp $ */ +/* $OpenBSD: misc.c,v 1.33 2004/07/22 16:36:28 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -22,7 +22,7 @@ */ #if !defined(lint) && !defined(LINT) -static char const rcsid[] = "$OpenBSD: misc.c,v 1.32 2004/07/09 16:22:02 deraadt Exp $"; +static char const rcsid[] = "$OpenBSD: misc.c,v 1.33 2004/07/22 16:36:28 millert Exp $"; #endif /* vix 26jan87 [RCS has the rest of the log] @@ -770,27 +770,26 @@ poke_daemon(const char *spool_dir, unsigned char cookie) { int sock = -1; struct sockaddr_un s_un; - if (utime(spool_dir, NULL) < 0) { - fprintf(stderr, "%s: unable to update mtime on %s\n", - ProgramName, spool_dir); - return; - } + (void) utime(spool_dir, NULL); /* old poke method */ if (snprintf(s_un.sun_path, sizeof s_un.sun_path, "%s/%s", - SPOOL_DIR, CRONSOCK) >= sizeof(s_un.sun_path)) { - s_un.sun_family = AF_UNIX; + SPOOL_DIR, CRONSOCK) >= sizeof(s_un.sun_path)) { + fprintf(stderr, "%s: %s/%s: path too long\n", + ProgramName, SPOOL_DIR, CRONSOCK); + return; + } + s_un.sun_family = AF_UNIX; #ifdef SUN_LEN - s_un.sun_len = SUN_LEN(&s_un); + s_un.sun_len = SUN_LEN(&s_un); #endif - (void) signal(SIGPIPE, SIG_IGN); - if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0 && - connect(sock, (struct sockaddr *)&s_un, sizeof(s_un)) == 0) - write(sock, &cookie, 1); - else - fprintf(stderr, "%s: warning, cron does not appear to be " - "running.\n", ProgramName); - if (sock >= 0) - close(sock); - (void) signal(SIGPIPE, SIG_DFL); - } + (void) signal(SIGPIPE, SIG_IGN); + if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0 && + connect(sock, (struct sockaddr *)&s_un, sizeof(s_un)) == 0) + write(sock, &cookie, 1); + else + fprintf(stderr, "%s: warning, cron does not appear to be " + "running.\n", ProgramName); + if (sock >= 0) + close(sock); + (void) signal(SIGPIPE, SIG_DFL); } |