https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268436
Bug ID: 268436
Summary: [libc] syslog() and vsyslog() do not preserve the
errno at the time of the call.
Product: Base System
Version: Unspecified
Hardware: Any
OS: Any
Status: New
Severity: Affects Many People
Priority: ---
Component: bin
Assignee: [email protected]
Reporter: [email protected]
Hello.
Since syslog() and vsyslog() do not preserve errno at the time of the call,
errno may change after calling syslog.
https://cgit.freebsd.org/src/tree/lib/libc/gen/syslog.c
https://github.com/freebsd/freebsd-src/blob/main/lib/libc/gen/syslog.c
I suggest this patch.
--- a/syslog.c
+++ b/syslog.c
@@ -348,7 +348,9 @@ vsyslog(int pri, const char *fmt, va_list ap)
THREAD_LOCK();
pthread_cleanup_push(syslog_cancel_cleanup, NULL);
+ int saved_errno = errno;
vsyslog1(pri, fmt, ap);
+ errno = saved_errno;
pthread_cleanup_pop(1);
}
--
You are receiving this mail because:
You are the assignee for the bug.