-/* $OpenBSD: syslog_r.c,v 1.19 2017/08/08 14:23:23 bluhm Exp $ */
+/* $OpenBSD: syslog_r.c,v 1.20 2024/04/03 04:36:53 deraadt Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
* The Regents of the University of California. All rights reserved.
{
int cnt;
char ch, *p, *t;
- int saved_errno;
+ int saved_errno = errno; /* use original errno */
#define TBUF_SIZE (LOG_MAXLINE+1)
#define FMT_SIZE (1024+1)
char *stdp = NULL, tbuf[TBUF_SIZE], fmt_cpy[FMT_SIZE];
/* Check priority against setlogmask values. */
if (!(LOG_MASK(LOG_PRI(pri)) & data->log_mask))
- return;
-
- saved_errno = errno;
+ goto done;
/* Set default facility if none specified. */
if ((pri & LOG_FACMASK) == 0)
* is not running or the kernel ran out of buffers.
*/
sendsyslog(tbuf, cnt, data->log_stat & LOG_CONS);
+done:
+ errno = saved_errno;
}
void