syslogd: Fix blocking of SIGHUP/ALRM during logmsg()

Only block signals *after* all sanity checking of log message has been
completed, otherwise we will end up with blocked SIGHUP and SIGALRM.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-29 10:20:54 +01:00
parent 05c5b6752d
commit 280b5fd3ec

View File

@ -1183,11 +1183,6 @@ static void logmsg(struct buf_msg *buffer)
textpri(buffer->pri), buffer->flags, buffer->hostname, buffer->app_name,
buffer->proc_id, buffer->msgid, buffer->sd, buffer->msg);
sigemptyset(&mask);
sigaddset(&mask, SIGHUP);
sigaddset(&mask, SIGALRM);
sigprocmask(SIG_BLOCK, &mask, NULL);
(void)gettimeofday(&tv, NULL);
now = tv.tv_sec;
if (!memcmp(&buffer->timestamp, &zero, sizeof(zero))) {
@ -1208,6 +1203,11 @@ static void logmsg(struct buf_msg *buffer)
prilev = LOG_PRI(buffer->pri);
sigemptyset(&mask);
sigaddset(&mask, SIGHUP);
sigaddset(&mask, SIGALRM);
sigprocmask(SIG_BLOCK, &mask, NULL);
/* log the message to the particular outputs */
if (!Initialized) {
f = &consfile;