From 4eb60b4fdb67761da170e4ece6609dbe1f3b0fc2 Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Sat, 21 Dec 2002 17:42:46 +0000 Subject: ChangeLogTag:Sat Dec 21 12:38:41 2002 Steve Huston --- ace/OS.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ace') diff --git a/ace/OS.cpp b/ace/OS.cpp index 6912d72b646..f6d94de214f 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -1056,6 +1056,9 @@ ACE_OS::snprintf (char *buf, size_t maxlen, const char *format, ...) # if defined (ACE_WIN32) ACE_OSCALL (ACE_SPRINTF_ADAPTER (::_vsnprintf (buf, maxlen, format, ap)), int, -1, result); + // Win32 doesn't 0-terminate the string if it overruns maxlen. + if (result == -1) + buf[maxlen-1] = '\0'; # else ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vsnprintf (buf, maxlen, format, ap)), int, -1, result); @@ -1093,6 +1096,9 @@ ACE_OS::snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format, ...) // as a substitute, which does have the same signature as the UNIX98 one. ACE_OSCALL (ACE_SPRINTF_ADAPTER (::_vsnwprintf (buf, maxlen, format, ap)), int, -1, result); + // Win32 doesn't 0-terminate the string if it overruns maxlen. + if (result == -1) + buf[maxlen-1] = '\0'; # else ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vswprintf (buf, maxlen, format, ap)), int, -1, result); -- cgit v1.2.1