From: Eric Leblond Date: Mon, 3 Feb 2014 23:33:47 +0000 (+0100) Subject: ulogd: avoid potential double print of message X-Git-Tag: ulogd-2.0.4~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a6c850e9f439b73e31f81dac6cb02b9bafbc866;p=thirdparty%2Fulogd2.git ulogd: avoid potential double print of message In case there is no logfile, ulogd could possibly display each log message twice to stderr. --- diff --git a/src/ulogd.c b/src/ulogd.c index 2c0fbd1..810f828 100644 --- a/src/ulogd.c +++ b/src/ulogd.c @@ -442,7 +442,7 @@ void __ulogd_log(int level, char *file, int line, const char *format, ...) timestr = ctime(&tm); timestr[strlen(timestr)-1] = '\0'; fprintf(outfd, "%s <%1.1d> %s:%d ", timestr, level, file, line); - if (verbose) + if (verbose && outfd != stderr) fprintf(stderr, "%s <%1.1d> %s:%d ", timestr, level, file, line); @@ -452,7 +452,7 @@ void __ulogd_log(int level, char *file, int line, const char *format, ...) /* flush glibc's buffer */ fflush(outfd); - if (verbose) { + if (verbose && outfd != stderr) { va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap);