From 46e4aeca3552493ef601e25a49903a9fe0d1985a Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 3 Feb 2015 19:56:32 +0100 Subject: [PATCH 07/10] Fix crash running test-syslog on windows/wine. Use seperate buffer in _dbus_system_logv() to avoid crash in vsprintf(). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92538 --- dbus/dbus-sysdeps-util-win.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index bda2283..273dff9 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -335,7 +335,8 @@ _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args { char *s = ""; char buf[1024]; - + char format[1024]; + switch(severity) { case DBUS_SYSTEM_LOG_INFO: s = "info"; break; @@ -344,8 +345,8 @@ _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args case DBUS_SYSTEM_LOG_FATAL: s = "fatal"; break; } - sprintf(buf,"%s%s",s,msg); - vsprintf(buf,buf,args); + snprintf(format, sizeof(format), "%s%s", s ,msg); + vsnprintf(buf, sizeof(buf), format, args); OutputDebugStringA(buf); if (severity == DBUS_SYSTEM_LOG_FATAL) -- 1.8.4.5