[uClibc-cvs] CVS uClibc/libc/misc/syslog
CVS User andersen
andersen at codepoet.org
Tue Jan 11 11:31:56 UTC 2005
Update of /var/cvs/uClibc/libc/misc/syslog
In directory nail:/tmp/cvs-serv16142/libc/misc/syslog
Modified Files:
syslog.c
Log Message:
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:
--- /var/cvs/uClibc/libc/misc/syslog/syslog.c 2004/04/06 12:19:22 1.13
+++ /var/cvs/uClibc/libc/misc/syslog/syslog.c 2005/01/11 11:31:55 1.14
@@ -206,7 +206,15 @@
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;
More information about the uClibc-cvs
mailing list