From: Philip Homburg Date: Mon, 23 Apr 2007 13:04:31 +0000 (+0000) Subject: Use sprintf to avoid buffer overflows. X-Git-Tag: v3.1.4~429 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/doxygen.log?a=commitdiff_plain;h=b4f69942784b63be91b64bc133a068f640403c5f;p=minix.git Use sprintf to avoid buffer overflows. --- diff --git a/commands/syslogd/syslogd.c b/commands/syslogd/syslogd.c index 7f4e1411b..4225e17e2 100644 --- a/commands/syslogd/syslogd.c +++ b/commands/syslogd/syslogd.c @@ -233,7 +233,8 @@ void fprintlog(struct filed * fLog, int flags, char *message) } else message = fLog->f_prevline; } - sprintf(line, "%s %s %s", fLog->f_lasttime, fLog->f_prevhost, message); + snprintf(line, sizeof(line), "%s %s %s", + fLog->f_lasttime, fLog->f_prevhost, message); DEBUG(dprintf("Logging to %s", TypeNames[fLog->f_type]);) fLog->f_time = now; switch (fLog->f_type) { @@ -640,7 +641,7 @@ void printkline(char *hname, char *msg) int ch, pri = DEFUPRI; /* Copies message to local buffer, adding source program tag */ - sprintf(line, "kernel: %s", msg); + snprintf(line, sizeof(line), "kernel: %s", msg); logmsg(LOG_KERN | LOG_INFO, line, hname, ADDDATE); return;