e48796b26b
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. |
||
---|---|---|
.. | ||
Base64.c | ||
Base64.h.in | ||
CMakeEmptyInputFile.in | ||
CMakeLists.txt | ||
CPU.h.in | ||
CTestConfig.cmake | ||
CommandLineArguments.cxx | ||
CommandLineArguments.hxx.in | ||
Configure.h.in | ||
Configure.hxx.in | ||
Copyright.txt | ||
DateStamp.h.in | ||
Directory.cxx | ||
Directory.hxx.in | ||
DynamicLoader.cxx | ||
DynamicLoader.hxx.in | ||
EncodeExecutable.c | ||
ExtraTest.cmake.in | ||
FundamentalType.h.in | ||
Glob.cxx | ||
Glob.hxx.in | ||
IOStream.cxx | ||
IOStream.hxx.in | ||
MD5.c | ||
MD5.h.in | ||
Process.h.in | ||
ProcessFwd9x.c | ||
ProcessUNIX.c | ||
ProcessWin32.c | ||
README.txt | ||
Registry.cxx | ||
Registry.hxx.in | ||
RegularExpression.cxx | ||
RegularExpression.hxx.in | ||
SharedForward.h.in | ||
String.c | ||
String.h.in | ||
String.hxx.in | ||
System.c | ||
System.h.in | ||
SystemInformation.cxx | ||
SystemInformation.hxx.in | ||
SystemTools.cxx | ||
SystemTools.hxx.in | ||
Terminal.c | ||
Terminal.h.in | ||
auto_ptr.hxx.in | ||
hash_fun.hxx.in | ||
hash_map.hxx.in | ||
hash_set.hxx.in | ||
hashtable.hxx.in | ||
kwsysDateStamp.cmake | ||
kwsysDateStamp.py | ||
kwsysHeaderDump.pl | ||
kwsysPlatformTests.cmake | ||
kwsysPlatformTestsC.c | ||
kwsysPlatformTestsCXX.cxx | ||
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 | ||
testCommandLineArguments.cxx | ||
testCommandLineArguments1.cxx | ||
testDynamicLoader.cxx | ||
testDynload.c | ||
testEncode.c | ||
testFail.c | ||
testHashSTL.cxx | ||
testIOS.cxx | ||
testProcess.c | ||
testRegistry.cxx | ||
testSharedForward.c.in | ||
testSystemInformation.cxx | ||
testSystemTools.bin | ||
testSystemTools.cxx | ||
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.