From: Karel Zak Date: Thu, 12 Oct 2017 12:21:27 +0000 (+0200) Subject: logger: keep header generators independent on connection X-Git-Tag: v2.31~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2d4c226dfb715bfc8f422ed7da7ef7fe441c1e4e;p=thirdparty%2Futil-linux.git logger: keep header generators independent on connection * avoid memory leaks * don't use incomplete or header after free() Signed-off-by: Karel Zak --- diff --git a/misc-utils/logger.c b/misc-utils/logger.c index ea4bcf0b39..862b8a48bb 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -523,8 +523,6 @@ static void syslog_rfc3164_header(struct logger_ctl *const ctl) char pid[30], *hostname; *pid = '\0'; - if (ctl->fd < 0) - return; if (ctl->pid) snprintf(pid, sizeof(pid), "[%d]", ctl->pid); @@ -752,9 +750,6 @@ static void syslog_rfc5424_header(struct logger_ctl *const ctl) char *structured = NULL; struct list_head *sd; - if (ctl->fd < 0) - return; - if (ctl->rfc5424_time) { struct timeval tv; struct tm *tm; @@ -881,6 +876,7 @@ static void syslog_local_header(struct logger_ctl *const ctl) static void generate_syslog_header(struct logger_ctl *const ctl) { free(ctl->hdr); + ctl->hdr = NULL; ctl->syslogfp(ctl); }