diff options
author | Patrick Plagwitz | 2015-04-06 23:50:46 +0200 |
---|---|---|
committer | Sami Kerola | 2015-04-07 09:51:05 +0200 |
commit | 4a8919a4e5b28a47cd61fc8b774a6eaee943b90e (patch) | |
tree | ec6ad87899bcd5e8e2ca87c21b7c0766f1dffdee /misc-utils/logger.c | |
parent | wall: do not use a temporary file. (diff) | |
download | kernel-qcow2-util-linux-4a8919a4e5b28a47cd61fc8b774a6eaee943b90e.tar.gz kernel-qcow2-util-linux-4a8919a4e5b28a47cd61fc8b774a6eaee943b90e.tar.xz kernel-qcow2-util-linux-4a8919a4e5b28a47cd61fc8b774a6eaee943b90e.zip |
logger: generate header when reading message from stdin
This change fixes crashing error, that ought not to be simply avoided.
$ echo foo | logger -n localhost
Segmentation fault (core dumped)
If the ctl->hdr is just checked not to be NULL syslog message will not
have valid header, so generating such is not optional when reading
message from stdin and writing it to remote destination.
Reviewed-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Patrick Plagwitz <patrick.plagwitz@fau.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'misc-utils/logger.c')
-rw-r--r-- | misc-utils/logger.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/misc-utils/logger.c b/misc-utils/logger.c index edc94836b..753cd7f99 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -582,14 +582,14 @@ static void logger_open(struct logger_ctl *ctl) ctl->fd = inet_socket(ctl->server, ctl->port, ctl->socket_type); if (!ctl->syslogfp) ctl->syslogfp = syslog_rfc5424_header; - return; - } - if (!ctl->unix_socket) - ctl->unix_socket = _PATH_DEVLOG; + } else { + if (!ctl->unix_socket) + ctl->unix_socket = _PATH_DEVLOG; - ctl->fd = unix_socket(ctl, ctl->unix_socket, ctl->socket_type); - if (!ctl->syslogfp) - ctl->syslogfp = syslog_local_header; + ctl->fd = unix_socket(ctl, ctl->unix_socket, ctl->socket_type); + if (!ctl->syslogfp) + ctl->syslogfp = syslog_local_header; + } if (!ctl->tag) ctl->tag = xgetlogin(); generate_syslog_header(ctl); |