From 8fb3fa969b6a4c0aa29a9415d01ea0d86a5e441e Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Tue, 5 Aug 2014 21:53:37 +0000 Subject: ChangeLogTag:Tue Aug 5 21:49:12 UTC 2014 Steve Huston --- ACE/ChangeLog | 9 +++++++++ ACE/ace/OS_NS_stdio.inl | 4 +++- ACE/ace/Process.cpp | 8 +++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ACE/ChangeLog b/ACE/ChangeLog index 24383398046..51fad58486e 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,12 @@ +Tue Aug 5 21:49:12 UTC 2014 Steve Huston + + * ace/Process.cpp (setenv): Use the correct format string for + non-Windows wide-char builds. Fixes Bugzilla 4176. + + * ace/OS_NS_stdio.inl (vsnprintf): When trying to adapt C99 vswprintf + to return a required destination memory area, don't be fooled by a + real error such as formatting errors. Fixes Bugzilla 4177. + Tue Aug 5 17:14:04 UTC 2014 Steve Huston * ace/Process.cpp (setenv): Correctly re-process variable arg list if diff --git a/ACE/ace/OS_NS_stdio.inl b/ACE/ace/OS_NS_stdio.inl index 60031b4fd63..8e44c5a8f64 100644 --- a/ACE/ace/OS_NS_stdio.inl +++ b/ACE/ace/OS_NS_stdio.inl @@ -1115,7 +1115,9 @@ ACE_OS::vsnprintf (wchar_t *buffer, size_t maxlen, const wchar_t *format, va_lis // was available. Earlier variants of the vsnprintf() (e.g. UNIX98) // defined it to return -1. This method follows the C99 standard, // but needs to guess at the value; uses maxlen + 1. - if (result == -1) + // Note that a formatting failure also returns -1. On RHEL this is + // errno EINVAL. Don't indicate a simple memory shortage for that. + if (result == -1 && errno != EINVAL) result = static_cast (maxlen + 1); return result; diff --git a/ACE/ace/Process.cpp b/ACE/ace/Process.cpp index 0b41e371af3..6a6f51a93b9 100644 --- a/ACE/ace/Process.cpp +++ b/ACE/ace/Process.cpp @@ -994,9 +994,15 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name, ACE_NEW_RETURN (newformat, ACE_TCHAR[buflen], -1); ACE_Auto_Basic_Array_Ptr safe_newformat (newformat); +# if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + const ACE_TCHAR *fmt = ACE_TEXT ("%ls=%ls"); +# else + const ACE_TCHAR *fmt = ACE_TEXT ("%s=%s"); +# endif + // Add in the variable name. ACE_OS::sprintf (safe_newformat.get (), - ACE_TEXT ("%s=%s"), + fmt, variable_name, format); -- cgit v1.2.1