summaryrefslogtreecommitdiffstats
path: root/libc/misc
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2005-01-11 11:31:55 +0000
committerEric Andersen <andersen@codepoet.org>2005-01-11 11:31:55 +0000
commitc243c796177ca2cd595f4ab394d4f4911812027d (patch)
tree2f13dc3e718ac217a6bed97bfa1304462fa65d0b /libc/misc
parentb3e4a879a534add27e8435b11628d4d79d706434 (diff)
downloaduClibc-alpine-c243c796177ca2cd595f4ab394d4f4911812027d.tar.bz2
uClibc-alpine-c243c796177ca2cd595f4ab394d4f4911812027d.tar.xz
Jean writes:
Hello, under some circumstances the following small example prints lots of garbage onto the console and into the syslog: #include <syslog.h> int main () { openlog("foo", LOG_CONS|LOG_NDELAY|LOG_PID|LOG_PERROR, LOG_DAEMON); syslog (LOG_WARNING, "mlock: %m"); return 1; } The reason is, that sprintf returns with -1 and vsyslog dumps the complete buffer onto stderr and the syslogd socket. The following patch would fix the problem:
Diffstat (limited to 'libc/misc')
-rw-r--r--libc/misc/syslog/syslog.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libc/misc/syslog/syslog.c b/libc/misc/syslog/syslog.c
index 250cb6ddc..e39e63a05 100644
--- a/libc/misc/syslog/syslog.c
+++ b/libc/misc/syslog/syslog.c
@@ -206,7 +206,15 @@ vsyslog( int pri, const char *fmt, va_list ap )
memmove(head_end + sizeof(truncate_msg), head_end,
end - head_end - sizeof(truncate_msg));
memcpy(head_end, truncate_msg, sizeof(truncate_msg));
- p = end - 1;
+ if (p < head_end) {
+ while (p < end && *p) {
+ p++;
+ }
+ }
+ else {
+ p = end - 1;
+ }
+
}
last_chr = p;