summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2024-04-03 04:36:54 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2024-04-03 04:36:54 +0000
commit2b220ddc91eacc87225b05e30a63941b0a697b4e (patch)
treea35956303f92c5ba8b6e8b22898d906ee2488a98
parent276c51c66e2affbcbac871291020704142eb6abd (diff)
Reading https://github.com/Geal/rust-syslog/issues/79, I came to a
related conclusion that our syslog_r should not stomp on errno. The errno being returned from sendsyslog() isn't exactly compatible with the what a legacy syslog_r() would do here anyways, and it is better to just be void and non-stomping; ok millert bluhm
-rw-r--r--lib/libc/gen/syslog_r.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libc/gen/syslog_r.c b/lib/libc/gen/syslog_r.c
index 3417a651d7e..68dcff11afa 100644
--- a/lib/libc/gen/syslog_r.c
+++ b/lib/libc/gen/syslog_r.c
@@ -1,4 +1,4 @@
-/* $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.
@@ -72,7 +72,7 @@ __vsyslog_r(int pri, struct syslog_data *data,
{
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];
@@ -89,9 +89,7 @@ __vsyslog_r(int pri, struct syslog_data *data,
/* 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)
@@ -187,6 +185,8 @@ __vsyslog_r(int pri, struct syslog_data *data,
* is not running or the kernel ran out of buffers.
*/
sendsyslog(tbuf, cnt, data->log_stat & LOG_CONS);
+done:
+ errno = saved_errno;
}
void