CMake/Source/kwsys
Brad King e48796b26b KWSys: Fix SystemTools environment memory handling (#13156)
The SystemTools::PutEnv function tries to provide the "putenv" API
without leaking memory.  However, the kwsysDeletingCharVector singleton
frees memory that may still be referenced by the environment table,
having been placed there by putenv.  If any static destruction or
processing by an external tool happens after the singleton is destroyed
and accesses the environment it will read invalid memory.

Replace use of putenv with setenv/unsetenv when available.  The latter
manage internal copies of the values passed instead of referencing the
original memory.  When setenv/unsetenv are not available use putenv with
a singleton that removes its values from the environment before freeing
their memory.  This requires an "unputenv" implementation.  On at least
some platforms it must be written in terms of "putenv" because other
APIs are not available and direct modification of the "environ" global
is not safe (e.g. on Windows there is interaction with "wenviron").
Fortunately either putenv("A=") or putenv("A") will remove "A" from the
environment on these platforms.  On other platforms fall back to direct
manipulation of "environ".

Also add UnPutEnv to the API and add a test for the behavior of both.
2012-04-27 08:13:52 -04:00
..
Base64.c
Base64.h.in
CMakeEmptyInputFile.in
CMakeLists.txt KWSys: Fix SystemTools environment memory handling (#13156) 2012-04-27 08:13:52 -04:00
CPU.h.in
CTestConfig.cmake
CommandLineArguments.cxx KWSys: Address Intel compiler remarks 2011-11-01 10:49:25 -04:00
CommandLineArguments.hxx.in
Configure.h.in Silence warnings on sgi compiler. 2010-05-12 09:37:42 -04:00
Configure.hxx.in KWSys: Cleanup putenv leak option implementation 2010-06-29 08:50:03 -04:00
Copyright.txt
DateStamp.h.in
Directory.cxx
Directory.hxx.in
DynamicLoader.cxx KWSys: Configure DynamicLoader library prefix/suffix 2010-06-10 09:26:32 -04:00
DynamicLoader.hxx.in KWSys: Configure DynamicLoader library prefix/suffix 2010-06-10 09:26:32 -04:00
EncodeExecutable.c KWSys: Fix leaked FILE in EncodeExecutable error case 2011-05-09 08:40:03 -04:00
ExtraTest.cmake.in
FundamentalType.h.in Fix KWSys FundamentalType for Universal Binaries 2009-11-20 08:38:18 -05:00
Glob.cxx KWSys: Add symlinks to directories as files (#12284) 2011-09-06 13:20:02 -04:00
Glob.hxx.in KWSys: Remove always-true dir_only parameter 2011-09-06 13:10:05 -04:00
IOStream.cxx
IOStream.hxx.in
MD5.c KWSys: Suppress -Wcast-align warning in MD5.c 2010-09-10 09:00:02 -04:00
MD5.h.in
Process.h.in Convert KWSys to OSI-approved BSD License 2009-09-28 11:37:35 -04:00
ProcessFwd9x.c
ProcessUNIX.c KWSys: Teach Process to error on empty command 2010-06-11 11:00:38 -04:00
ProcessWin32.c KWSys: Teach Process to error on empty command 2010-06-11 11:00:38 -04:00
README.txt
Registry.cxx KWSys: Avoid passing string literal as char* 2010-12-28 09:57:09 -05:00
Registry.hxx.in
RegularExpression.cxx
RegularExpression.hxx.in
SharedForward.h.in KWSys SharedForward: Add OpenBSD support 2010-04-19 16:30:23 -04:00
String.c
String.h.in
String.hxx.in COMP: remove exporting String as VS10 attempts to export its parents (basic_string) which causes all kinds of multiply defined symbols at link time. 2010-01-26 17:19:23 -05:00
System.c Revert commit: CMake: quote ':' in Windows NMake Makefiles (#9963) -- it was not the right fix and caused mucho other problemo 2010-09-09 12:40:04 -04:00
System.h.in
SystemInformation.cxx KWSys: Address Intel compiler remarks 2011-11-01 10:49:25 -04:00
SystemInformation.hxx.in Try to fix missing size_t on qnx 2009-11-16 17:03:59 -05:00
SystemTools.cxx KWSys: Fix SystemTools environment memory handling (#13156) 2012-04-27 08:13:52 -04:00
SystemTools.hxx.in KWSys: Fix SystemTools environment memory handling (#13156) 2012-04-27 08:13:52 -04:00
Terminal.c KWSys: Recognize color TERM=screen-256color-bce (#12287) 2011-06-19 18:17:07 -04:00
Terminal.h.in
auto_ptr.hxx.in
hash_fun.hxx.in KWSys: Fix std::string hash function for Borland 2011-09-01 08:22:03 -04:00
hash_map.hxx.in
hash_set.hxx.in
hashtable.hxx.in Silence warnings on sgi compiler. 2010-05-12 09:37:42 -04:00
kwsysDateStamp.cmake KWSys Nightly Date Stamp 2012-04-20 09:37:16 -04:00
kwsysDateStamp.py
kwsysHeaderDump.pl
kwsysPlatformTests.cmake Fix KWSYS_PLATFORM_INFO_TEST when user removes tree 2010-02-12 10:46:50 -05:00
kwsysPlatformTestsC.c Fix KWSys FundamentalType for Universal Binaries 2009-11-20 08:38:18 -05:00
kwsysPlatformTestsCXX.cxx KWSys: Fix SystemTools environment memory handling (#13156) 2012-04-27 08:13:52 -04:00
kwsysPrivate.h
kwsys_cstddef.hxx.in
kwsys_ios_fstream.h.in
kwsys_ios_iosfwd.h.in
kwsys_ios_iostream.h.in
kwsys_ios_sstream.h.in
kwsys_stl.hxx.in
kwsys_stl_string.hxx.in
testAutoPtr.cxx Fix for bug #10550, work around instantiation out of scope 2010-04-28 17:42:22 -04:00
testCommandLineArguments.cxx
testCommandLineArguments1.cxx
testDynamicLoader.cxx
testDynload.c
testEncode.c
testFail.c
testHashSTL.cxx
testIOS.cxx
testProcess.c KWSys: Avoid undefined behavior in Process crash tests 2010-07-09 10:40:06 -04:00
testRegistry.cxx
testSharedForward.c.in
testSystemInformation.cxx
testSystemTools.bin
testSystemTools.cxx KWSys: Fix SystemTools environment memory handling (#13156) 2012-04-27 08:13:52 -04:00
testSystemTools.h.in
testTerminal.c

README.txt

KWSys provides a platform-independent API to many common system
features that are implemented differently on every platform.  This
library is intended to be shared among many projects, so it has a
configurable namespace.  Each project should configure KWSys to use a
namespace unique to itself.  See comments in CMakeLists.txt for
details.

You are probably reading this file in the source tree of a surrounding
project.  In that case, see "../README.kwsys" for details of using
KWSys in your project.