summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2014-08-05 20:02:12 +0000
committerSteve Huston <shuston@riverace.com>2014-08-05 20:02:12 +0000
commit80460fd691fbc007370abefa2319ab583ab4f853 (patch)
treef4f00fbaf7e718f9d1586e5efee01994397d8857
parentba216f09a07500b0a425ca96e7f0fd06d93f1cb2 (diff)
downloadATCD-80460fd691fbc007370abefa2319ab583ab4f853.tar.gz
ChangeLogTag:Tue Aug 5 17:14:04 UTC 2014 Steve Huston <shuston@riverace.com>
-rw-r--r--ACE/ChangeLog6
-rw-r--r--ACE/ace/Process.cpp18
2 files changed, 17 insertions, 7 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index cc7b0789194..24383398046 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,9 @@
+Tue Aug 5 17:14:04 UTC 2014 Steve Huston <shuston@riverace.com>
+
+ * ace/Process.cpp (setenv): Correctly re-process variable arg list if
+ first attempt at formatting the value(s) fails due to lack of
+ space. Fixes Bugzilla 4175.
+
Thu Jun 5 14:24:58 UTC 2014 Steve Huston <shuston@riverace.com>
* include/makeinclude/platform_aix_ibm.GNU: Add XL C++ 12.1 to the
diff --git a/ACE/ace/Process.cpp b/ACE/ace/Process.cpp
index 6b3dfb6f00f..0b41e371af3 100644
--- a/ACE/ace/Process.cpp
+++ b/ACE/ace/Process.cpp
@@ -1000,10 +1000,6 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name,
variable_name,
format);
- // Start varargs.
- va_list argp;
- va_start (argp, format);
-
// Add the rest of the varargs.
size_t tmp_buflen = buflen;
if (DEFAULT_COMMAND_LINE_BUF_LEN > buflen)
@@ -1018,7 +1014,15 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name,
do
{
+ // Must restart varargs on each time through this loop,
+ va_list argp;
+ va_start (argp, format);
+
retval = ACE_OS::vsnprintf (safe_stack_buf.get (), tmp_buflen, safe_newformat.get (), argp);
+
+ // End varargs.
+ va_end (argp);
+
if (retval > ACE_Utils::truncate_cast<int> (tmp_buflen))
{
tmp_buflen *= 2;
@@ -1040,7 +1044,10 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name,
// ALERT: Since we have to use vsprintf here, there is still a chance that
// the stack_buf overflows, i.e., the length of the resulting string
// can still possibly go beyond the allocated stack_buf.
+ va_list argp;
+ va_start (argp, format);
retval = ACE_OS::vsprintf (safe_stack_buf.get (), safe_newformat.get (), argp);
+ va_end (argp);
if (retval == -1)
// vsprintf is failed.
return -1;
@@ -1050,9 +1057,6 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name,
return -1;
}
- // End varargs.
- va_end (argp);
-
// Append the string to our environment buffer.
if (this->setenv_i (safe_stack_buf.get (),
ACE_OS::strlen (safe_stack_buf.get ())) == -1)