summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ChangeLogs/ChangeLog-03a5
-rw-r--r--ace/OS.cpp6
3 files changed, 16 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 31bf8e5e640..06348e7fe82 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Dec 21 12:38:41 2002 Steve Huston <shuston@riverace.com>
+
+ * ace/OS.cpp (snprintf): Win32 doesn't 0-terminate the string if
+ the maxlen is exceed, so terminate the string in that case.
+
Sat Dec 21 14:36:43 UTC 2002 Johnny Willemsen <jwillemsen@remedy.nl>
* include/makeinclude/platform_cygwin32.GNU:
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index 31bf8e5e640..06348e7fe82 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,3 +1,8 @@
+Sat Dec 21 12:38:41 2002 Steve Huston <shuston@riverace.com>
+
+ * ace/OS.cpp (snprintf): Win32 doesn't 0-terminate the string if
+ the maxlen is exceed, so terminate the string in that case.
+
Sat Dec 21 14:36:43 UTC 2002 Johnny Willemsen <jwillemsen@remedy.nl>
* include/makeinclude/platform_cygwin32.GNU:
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);