From 5090f1c03e367f30fe4a1f21febc17e6dee3561e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Thu, 6 Mar 2014 23:14:03 +0000 Subject: [PATCH 5/9] Fix use of printf on W32 Don't print FROM and TO the same string. None of the printf implementations that i've tried support this. Use snprintf instead of printf, to avoid buffer overruns. https://bugs.freedesktop.org/show_bug.cgi?id=75861 --- 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 4678b11..b56d75e 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -302,6 +302,7 @@ _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args { char *s = ""; char buf[1024]; + int printed; switch(severity) { @@ -309,9 +310,9 @@ _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args case DBUS_SYSTEM_LOG_SECURITY: s = "security"; break; case DBUS_SYSTEM_LOG_FATAL: s = "fatal"; break; } - - sprintf(buf,"%s%s",s,msg); - vsprintf(buf,buf,args); + printed = snprintf(buf, 1024, "%s ", s); + if (printed >= 0) + vsnprintf(&buf[printed], 1024 - printed, msg, args); OutputDebugStringA(buf); if (severity == DBUS_SYSTEM_LOG_FATAL) -- 1.8.4