From: Ondrej Zajicek Date: Fri, 14 Mar 2025 15:49:36 +0000 (+0100) Subject: Log: Fix handling of L_BUG messages X-Git-Tag: v2.17~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=71ca7d75d72ce869cad4962b0d78ff12bcd79f27;p=thirdparty%2Fbird.git 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. --- diff --git a/lib/birdlib.h b/lib/birdlib.h index 26ebf9cc5..5687f10bd 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -172,6 +172,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 6c7cac540..7caf659f7 100644 --- a/sysdep/unix/log.c +++ b/sysdep/unix/log.c @@ -63,7 +63,7 @@ static int main_thread_self(void) { return 1; } #ifdef HAVE_SYSLOG_H #include -static int syslog_priorities[] = { +static int syslog_priorities[L_MAX] = { LOG_DEBUG, LOG_DEBUG, LOG_DEBUG, @@ -77,7 +77,7 @@ static int syslog_priorities[] = { }; #endif -static char *class_names[] = { +static char *class_names[L_MAX] = { "???", "DBG", "TRACE", @@ -302,7 +302,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); @@ -318,7 +318,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);