diff options
author | Karel Zak | 2017-10-12 14:21:27 +0200 |
---|---|---|
committer | Karel Zak | 2017-10-12 14:21:27 +0200 |
commit | 2d4c226dfb715bfc8f422ed7da7ef7fe441c1e4e (patch) | |
tree | 8a99da5122e53840cd5bae9a6ec390ed83b659a6 /misc-utils/logger.c | |
parent | fincore: make sure mmap(NULL, ...) [coverity scan] (diff) | |
download | kernel-qcow2-util-linux-2d4c226dfb715bfc8f422ed7da7ef7fe441c1e4e.tar.gz kernel-qcow2-util-linux-2d4c226dfb715bfc8f422ed7da7ef7fe441c1e4e.tar.xz kernel-qcow2-util-linux-2d4c226dfb715bfc8f422ed7da7ef7fe441c1e4e.zip |
logger: keep header generators independent on connection
* avoid memory leaks
* don't use incomplete or header after free()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/logger.c')
-rw-r--r-- | misc-utils/logger.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/misc-utils/logger.c b/misc-utils/logger.c index ea4bcf0b3..862b8a48b 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); } |