bus: Properly va_copy() argument list before passing it to printf() functions
authorMartin Willi <martin@revosec.ch>
Thu, 19 Jun 2014 08:10:54 +0000 (10:10 +0200)
committerMartin Willi <martin@revosec.ch>
Thu, 19 Jun 2014 08:10:54 +0000 (10:10 +0200)
As we later potentially use args again, we can't consume it with printf
functions without copying it first. Clone list before passing it to any
consuming function.

Fixes #621.

src/libcharon/bus/bus.c

index d467c33..d1c138c 100644 (file)
@@ -391,7 +391,9 @@ METHOD(bus_t, vlog, void,
                {
                        len++;
                        data.message = malloc(len);
-                       len = vsnprintf(data.message, len, format, args);
+                       va_copy(data.args, args);
+                       len = vsnprintf(data.message, len, format, data.args);
+                       va_end(data.args);
                }
                if (len > 0)
                {