summaryrefslogtreecommitdiffstats
path: root/src/util/debug.c
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2014-02-20 13:11:27 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-02-20 21:19:37 +0100
commitaa41947da76750427cdc4402cc60097063eb668e (patch)
tree5287205a76cc397c69aa44a95ef1e9f1e7e5693d /src/util/debug.c
parent0b5422c874a0d234b864a28cf18489a7e7ef17f6 (diff)
downloadsssd-aa41947da76750427cdc4402cc60097063eb668e.tar.gz
sssd-aa41947da76750427cdc4402cc60097063eb668e.tar.xz
sssd-aa41947da76750427cdc4402cc60097063eb668e.zip
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. Reviewed-by: Sumit Bose <sbose@redhat.com> Reviewed-by: Stephen Gallagher <sgallagh@redhat.com>
Diffstat (limited to 'src/util/debug.c')
-rw-r--r--src/util/debug.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/util/debug.c b/src/util/debug.c
index 9cd0f41ff..1db3693a1 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