From: Robert Luberda <robert@debian.org>
Date: Sun, 4 Dec 2011 16:56:57 +0100
Subject: 12 Use vnsprintf.
error.c: Use vsnprintf() instead of vprintf() to fix a crash
occurring when syslog logging is enabled and total length
of arguments passed to super is greater then 1300 characters.
rsyslog.c: Do the same just in case.
---
error.c | 4 ++--
rsyslog.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/error.c b/error.c
index 0b91ad9..30529fa 100644
--- a/error.c
+++ b/error.c
@@ -346,7 +346,7 @@ Error(
if (tag)
StrLCat(newfmt, tag, sizeof(newfmt));
va_start(ap, fmt);
- (void) vsprintf(buf, newfmt, ap);
+ (void) vsnprintf(buf, sizeof(buf), newfmt, ap);
va_end(ap);
if (show_perror)
StrLCat(buf, Strerror(error), sizeof(buf));
@@ -515,7 +515,7 @@ va_dcl
StrLCat(newfmt, fmt, sizeof(newfmt));
if (tag)
StrLCat(newfmt, tag, sizeof(newfmt));
- (void) vsprintf(buf, newfmt, ap);
+ (void) vsnprintf(buf, sizeof(buf), newfmt, ap);
va_end(ap);
SysLog(error_priority, buf);
}
diff --git a/rsyslog.c b/rsyslog.c
index ed478d8..af1e571 100644
--- a/rsyslog.c
+++ b/rsyslog.c
@@ -103,7 +103,7 @@ static struct {
(void) sprintf(msg,"(%d) ", getpid());
if (*loginfo.ident)
(void) sprintf(msg+strlen(msg),"%s: ", loginfo.ident);
- (void) vsprintf(msg+strlen(msg), fmt, args);
+ (void) vsnprintf(msg+strlen(msg), sizeof(msg)-strlen(msg), fmt, args);
va_end(args);
/*
--