]> 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)
committerOndrej Zajicek <santiago@crfreenet.org>
Fri, 14 Mar 2025 15:49:36 +0000 (16:49 +0100)
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 26ebf9cc5ed23e3aa26157669440834a446e7bac..5687f10bd2f5467e9f63081ad1b6a38a2f66bd4d 100644 (file)
@@ -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 */
index 6c7cac54076d74ddce9f8d377a505348f3dceb70..7caf659f7b7327e999e4918ee2e23615b6f67aee 100644 (file)
@@ -63,7 +63,7 @@ static int main_thread_self(void) { return 1; }
 #ifdef HAVE_SYSLOG_H
 #include <sys/syslog.h>
 
-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);