summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-12-17 02:17:10 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-12-17 02:17:10 +0000
commitf4fe840df4b53434402d6b1f80b3f887a27b2162 (patch)
tree70a2221ce97fcecd131fa6f22436b42825e8528f /usr.sbin
parentc5dcb0430c6899e78fbba6239a0ba2ca78d15c91 (diff)
use snprintf when storing the string from strerror(). Who knows how
long it could be esp. when locales come into the picture.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/cron/misc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.sbin/cron/misc.c b/usr.sbin/cron/misc.c
index 4b78d69a227..1ecccd4c566 100644
--- a/usr.sbin/cron/misc.c
+++ b/usr.sbin/cron/misc.c
@@ -16,7 +16,7 @@
*/
#if !defined(lint) && !defined(LINT)
-static char rcsid[] = "$Id: misc.c,v 1.2 1996/11/01 23:27:37 millert Exp $";
+static char rcsid[] = "$Id: misc.c,v 1.3 1996/12/17 02:17:09 millert Exp $";
#endif
/* vix 26jan87 [RCS has the rest of the log]
@@ -267,7 +267,7 @@ acquire_daemonlock(closeflag)
if ((-1 == (fd = open(pidfile, O_RDWR|O_CREAT, 0644)))
|| (NULL == (fp = fdopen(fd, "r+")))
) {
- sprintf(buf, "can't open or create %s: %s",
+ snprintf(buf, sizeof buf, "can't open or create %s: %s",
pidfile, strerror(errno));
fprintf(stderr, "%s: %s\n", ProgramName, buf);
log_it("CRON", getpid(), "DEATH", buf);
@@ -278,7 +278,8 @@ acquire_daemonlock(closeflag)
int save_errno = errno;
fscanf(fp, "%d", &otherpid);
- sprintf(buf, "can't lock %s, otherpid may be %d: %s",
+ snprintf(buf, sizeof buf,
+ "can't lock %s, otherpid may be %d: %s",
pidfile, otherpid, strerror(save_errno));
fprintf(stderr, "%s: %s\n", ProgramName, buf);
log_it("CRON", getpid(), "DEATH", buf);