]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Log: Fix handling of L_BUG messages
authorOndrej Zajicek <santiago@crfreenet.org>
Fri, 14 Mar 2025 15:49:36 +0000 (16:49 +0100)
committerMaria Matejka <mq@ucw.cz>
Mon, 31 Mar 2025 09:47:01 +0000 (11:47 +0200)
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
sysdep/unix/log.c

index bc7c334cb36bfc68c8ff5f433fa0a934dd625cb1..7c8f278d7c522783b9bc66da458dac9ad0e4b8ae 100644 (file)
@@ -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 */
index 384da303d79626af24213733c8ca84c86f0ff9bf..3bcdd931c9384493a3251a4d0dcbf348728d07e4 100644 (file)
@@ -56,7 +56,7 @@ static _Atomic uint logging_mask = ~0U;
 #ifdef HAVE_SYSLOG_H
 #include <sys/syslog.h>
 
-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);