summaryrefslogtreecommitdiffstats
path: root/misc-utils/logger.c
diff options
context:
space:
mode:
authorLaMont Jones2007-07-18 06:43:15 +0200
committerKarel Zak2007-07-24 00:22:20 +0200
commitdd0d1654792158b848d01b4c0e14a38847b485ef (patch)
tree43711d6b3a8dea77aa41788ce2136faf9d55013c /misc-utils/logger.c
parentfdisk: cleanup partname.c (diff)
downloadkernel-qcow2-util-linux-dd0d1654792158b848d01b4c0e14a38847b485ef.tar.gz
kernel-qcow2-util-linux-dd0d1654792158b848d01b4c0e14a38847b485ef.tar.xz
kernel-qcow2-util-linux-dd0d1654792158b848d01b4c0e14a38847b485ef.zip
logger: use snprintf instead of sprintf in logger.c
Signed-off-by: LaMont Jones <lamont@mmjgroup.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/logger.c')
-rw-r--r--misc-utils/logger.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 5241a1939..9a7cb0588 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -89,9 +89,8 @@ mysyslog(int fd, int logflags, int pri, char *tag, char *msg) {
time_t now;
if (fd > -1) {
- /* avoid snprintf - it does not exist on ancient systems */
if (logflags & LOG_PID)
- sprintf (pid, "[%d]", getpid());
+ snprintf (pid, sizeof(pid), "[%d]", getpid());
else
pid[0] = 0;
if (tag)
@@ -104,8 +103,7 @@ mysyslog(int fd, int logflags, int pri, char *tag, char *msg) {
(void)time(&now);
tp = ctime(&now)+4;
- /* do snprintf by hand - ugly, but for once... */
- sprintf(buf, "<%d>%.15s %.200s%s: %.400s",
+ snprintf(buf, sizeof(buf), "<%d>%.15s %.200s%s: %.400s",
pri, tp, cp, pid, msg);
if (write(fd, buf, strlen(buf)+1) < 0)