diff options
author | Steve Huston <shuston@riverace.com> | 2014-08-05 17:17:14 +0000 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 2014-08-05 17:17:14 +0000 |
commit | a62c796e267907773cd3fb55994f7306b843e897 (patch) | |
tree | 56c3162f4a26ea67b4ee8002eb239b78b5501d9d /ACE/ace/Process.cpp | |
parent | 94530344841f94451beb12dd583f59c3a9737d8f (diff) | |
download | ATCD-a62c796e267907773cd3fb55994f7306b843e897.tar.gz |
ChangeLogTag:Tue Aug 5 17:14:04 UTC 2014 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ACE/ace/Process.cpp')
-rw-r--r-- | ACE/ace/Process.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/ACE/ace/Process.cpp b/ACE/ace/Process.cpp index 58fc7749d7f..dfe23bb6f2c 100644 --- a/ACE/ace/Process.cpp +++ b/ACE/ace/Process.cpp @@ -1003,10 +1003,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) @@ -1021,7 +1017,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; @@ -1043,7 +1047,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; @@ -1053,9 +1060,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) |