]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
ulogd: avoid potential double print of message
authorEric Leblond <eric@regit.org>
Mon, 3 Feb 2014 23:33:47 +0000 (00:33 +0100)
committerEric Leblond <eric@regit.org>
Mon, 3 Feb 2014 23:33:47 +0000 (00:33 +0100)
In case there is no logfile, ulogd could possibly display each
log message twice to stderr.

src/ulogd.c

index 2c0fbd1f53ac75f30ea4a95c50e2582c9719c679..810f8284a7554b36ca25b5bfd57d9deefa5c7160 100644 (file)
@@ -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);