netifd: fix undefined va_list value which can cause crashes
authorMikael Magnusson <mikma@users.sourceforge.net>
Fri, 15 Dec 2023 22:19:47 +0000 (23:19 +0100)
committerFelix Fietkau <nbd@nbd.name>
Mon, 18 Dec 2023 10:47:15 +0000 (11:47 +0100)
Reinitialize the va_list value after the call
to netifd_udebug_vprintf() in netifd_log_message().

It's needed since netifd_udebug_vprintf() invokes vsnprintf()
which in turn invokes the va_arg() macro, and after that call
the va_list value is undefined.

Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
main.c

diff --git a/main.c b/main.c
index b6d2aa50060eb2aaf2aca4ffdbd282326830fda2..375c6ab7873d075d4a6aa6f7eea15bed9fc6ef4d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -126,6 +126,9 @@ netifd_log_message(int priority, const char *format, ...)
 
        va_start(vl, format);
        netifd_udebug_vprintf(format, vl);
+       va_end(vl);
+
+       va_start(vl, format);
        if (use_syslog)
                vsyslog(log_class[priority], format, vl);
        else