From 895736d49bd2bb318c69de99a05ea70c035c2da9 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 13 Jun 2024 11:48:40 -0400 Subject: syslog: fix incorrect LOG_MAKEPRI and LOG_FAC[MASK] macros these are nonstandard and unnecessary for using the associated functionality, but resulted in applications that used them malfunctioning. patch based on proposed fix by erny hombre. --- include/syslog.h | 6 +++--- src/misc/syslog.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/syslog.h b/include/syslog.h index 5b4d296..976fee0 100644 --- a/include/syslog.h +++ b/include/syslog.h @@ -18,7 +18,7 @@ extern "C" { #define LOG_PRIMASK 7 #define LOG_PRI(p) ((p)&LOG_PRIMASK) -#define LOG_MAKEPRI(f, p) (((f)<<3)|(p)) +#define LOG_MAKEPRI(f, p) ((f)|(p)) #define LOG_MASK(p) (1<<(p)) #define LOG_UPTO(p) ((1<<((p)+1))-1) @@ -46,8 +46,8 @@ extern "C" { #define LOG_LOCAL7 (23<<3) #define LOG_NFACILITIES 24 -#define LOG_FACMASK 0x3f8 -#define LOG_FAC(p) (((p)&LOG_FACMASK)>>3) +#define LOG_FACMASK 0xf8 +#define LOG_FAC(p) ((p)&LOG_FACMASK) #define LOG_PID 0x01 #define LOG_CONS 0x02 diff --git a/src/misc/syslog.c b/src/misc/syslog.c index 710202f..3131c78 100644 --- a/src/misc/syslog.c +++ b/src/misc/syslog.c @@ -128,7 +128,7 @@ static void _vsyslog(int priority, const char *message, va_list ap) static void __vsyslog(int priority, const char *message, va_list ap) { int cs; - if (!(log_mask & LOG_MASK(priority&7)) || (priority&~0x3ff)) return; + if (!(log_mask & LOG_MASK(priority&7)) || (priority&~0xff)) return; pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); LOCK(lock); _vsyslog(priority, message, ap); -- cgit v1.1