Skip to content

Commit

Permalink
Reading Geal/rust-syslog#79, I came to a
Browse files Browse the repository at this point in the history
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
  • Loading branch information
deraadt committed Apr 3, 2024
1 parent debb1f3 commit 368cffe
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/libc/gen/syslog_r.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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];
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 368cffe

Please sign in to comment.