ladybird/Tests/LibC/CMakeLists.txt
Jelle Raaijmakers f081a89cd9 LibC: Do not crash if putenv variable is invalid
Dr. POSIX says:

    Although the space used by string is no longer used once a new
    string which defines name is passed to putenv(), if any thread in
    the application has used getenv() to retrieve a pointer to this
    variable, it should not be freed by calling free(). If the changed
    environment variable is one known by the system (such as the locale
    environment variables) the application should never free the buffer
    used by earlier calls to putenv() for the same variable.

Applications _should_ not free the data passed to `putenv`, but they
_could_ in practice. I found that our Quake II port misbehaves in this
way, but does not crash on other platforms because glibc/musl `putenv`
does not assume that environment variables are correctly formatted.

The new behavior ignores environment variables without a '=' present,
and prevents excessively reading beyond the variable's name if the data
pointed to by the environment entry does not contain any null bytes.

With this change, our Quake II port no longer crashes when switching
from fullscreen to windowed mode.
2023-06-06 08:18:44 +02:00

45 lines
1 KiB
CMake

set(TEST_SOURCES
TestAbort.cpp
TestAssert.cpp
TestCType.cpp
TestEnvironment.cpp
TestIo.cpp
TestLibCExec.cpp
TestLibCDirEnt.cpp
TestLibCInodeWatcher.cpp
TestLibCMkTemp.cpp
TestLibCSetjmp.cpp
TestLibCString.cpp
TestLibCTime.cpp
TestMalloc.cpp
TestMath.cpp
TestMemalign.cpp
TestMemmem.cpp
TestMkDir.cpp
TestPthreadCancel.cpp
TestPthreadCleanup.cpp
TestPThreadPriority.cpp
TestPthreadSpinLocks.cpp
TestPthreadRWLocks.cpp
TestPwd.cpp
TestQsort.cpp
TestRaise.cpp
TestRealpath.cpp
TestScanf.cpp
TestSearch.cpp
TestSnprintf.cpp
TestStackSmash.cpp
TestStdio.cpp
TestStrlcpy.cpp
TestStrtodAccuracy.cpp
TestWchar.cpp
TestWctype.cpp
)
set_source_files_properties(TestMath.cpp PROPERTIES COMPILE_FLAGS "-fno-builtin")
set_source_files_properties(TestStrtodAccuracy.cpp PROPERTIES COMPILE_FLAGS "-fno-builtin-strtod")
foreach(source IN LISTS TEST_SOURCES)
serenity_test("${source}" LibC)
endforeach()