From 7a738f8f1d04120b757a2ee3b21d366f3553465d Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Fri, 14 Mar 2025 16:49:36 +0100 Subject: [PATCH] Log: Fix handling of L_BUG messages Due to an off-by-one error, L_BUG messages (e.g. from ASSERT()) were handled as L_DBG messages and therefore ignored by our CI. --- lib/birdlib.h | 1 + sysdep/unix/log.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/birdlib.h b/lib/birdlib.h index bc7c334cb..7c8f278d7 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -225,6 +225,7 @@ void vlog(int class, const char *msg, va_list args); #define L_AUTH "\007" /* Authorization failed etc. */ #define L_FATAL "\010" /* Fatal errors */ #define L_BUG "\011" /* BIRD bugs */ +#define L_MAX 10 void debug(const char *msg, ...); /* Printf to debug output */ void debug_safe(const char *msg); /* Printf to debug output, async-safe */ diff --git a/sysdep/unix/log.c b/sysdep/unix/log.c index 384da303d..3bcdd931c 100644 --- a/sysdep/unix/log.c +++ b/sysdep/unix/log.c @@ -56,7 +56,7 @@ static _Atomic uint logging_mask = ~0U; #ifdef HAVE_SYSLOG_H #include -static int syslog_priorities[] = { +static int syslog_priorities[L_MAX] = { LOG_DEBUG, LOG_DEBUG, LOG_DEBUG, @@ -70,7 +70,7 @@ static int syslog_priorities[] = { }; #endif -static char *class_names[] = { +static char *class_names[L_MAX] = { "???", "DBG", "TRACE", @@ -370,7 +370,7 @@ log_msg(const char *msg, ...) va_list args; va_start(args, msg); - if (*msg >= 1 && *msg <= 8) + if (*msg >= 1 && *msg < L_MAX) class = *msg++; vlog(class, msg, args); va_end(args); @@ -386,7 +386,7 @@ log_rl(struct tbf *f, const char *msg, ...) if (tbf_limit(f) && (f->drop > 1)) return; - if (*msg >= 1 && *msg <= 8) + if (*msg >= 1 && *msg < L_MAX) class = *msg++; va_start(args, msg); -- 2.47.2