>From a05c53c12ae81c59eca39bc66b2808cb86d0641b Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Thu, 20 Feb 2014 13:11:27 +0100 Subject: [PATCH] DEBUG: Fix crash after fallback from journal log if journal_send fail we should not use the same va_list in the fallback functions. va_list can be modiefied and it may cause crashes im some cases e.g. printing string. This patch use copy of initialised va_list for debug_vprintf function. --- src/util/debug.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/util/debug.c b/src/util/debug.c index 9cd0f41fffcda50bec52147b4bc9afe836392a17..1db3693a11bef9d6dced6b085e320d99c4fe3384 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -203,6 +203,7 @@ void debug_fn(const char *file, const char *format, ...) { va_list ap; + va_list ap_fallback; struct timeval tv; struct tm *tm; char datetime[20]; @@ -220,13 +221,15 @@ void debug_fn(const char *file, * searchable. */ va_start(ap, format); + va_copy(ap_fallback, ap); ret = journal_send(file, line, function, level, format, ap); + va_end(ap); if (ret != EOK) { /* Emergency fallback, send to STDERR */ - debug_vprintf(format, ap); + debug_vprintf(format, ap_fallback); debug_fflush(); } - va_end(ap); + va_end(ap_fallback); return; } #endif -- 1.8.5.3