serenity/Tests/LibC
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
..
CMakeLists.txt LibC: Do not crash if putenv variable is invalid 2023-06-06 08:18:44 +02:00
TestAbort.cpp Tests: Remove already-completed fixme 2023-01-07 10:01:37 -07:00
TestAssert.cpp
TestCType.cpp Tests: Add tests for <ctype.h> functions declared in the C Standard 2022-06-30 12:34:16 +01:00
TestEnvironment.cpp LibC: Do not crash if putenv variable is invalid 2023-06-06 08:18:44 +02:00
TestIo.cpp Tests: Prefer TRY_OR_FAIL() and MUST() over EXPECT(!.is_error()) 2023-05-14 15:39:38 -06:00
TestLibCDirEnt.cpp
TestLibCExec.cpp
TestLibCInodeWatcher.cpp Everywhere: Remove unused includes of LibC/stdlib.h 2023-01-02 20:27:20 -05:00
TestLibCMkTemp.cpp Tests: Prefer TRY_OR_FAIL() and MUST() over EXPECT(!.is_error()) 2023-05-14 15:39:38 -06:00
TestLibCSetjmp.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
TestLibCString.cpp LibC: Set saved_str to null in strtok_r if no tokens were found 2022-03-08 23:30:47 +01:00
TestLibCTime.cpp Everywhere: Explicitly specify the size in StringView constructors 2022-07-12 23:11:35 +02:00
TestMalloc.cpp Everywhere: Remove "LibC/" includes, add lint-rule against it 2023-01-07 10:01:37 -07:00
TestMath.cpp AK+Everywhere: Add AK_COMPILER_{GCC,CLANG} and use them most places 2022-10-04 23:35:07 +01:00
TestMemalign.cpp LibC+Tests: Reduce fuzz iteration in TestMemalign to speed up CI 2023-06-01 20:28:41 +01:00
TestMemmem.cpp AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
TestMkDir.cpp AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
TestPthreadCancel.cpp Tests: Add a test for pthread_cancel 2022-07-22 10:07:15 -07:00
TestPthreadCleanup.cpp Tests: Move the LibPthread tests to the correct namespace 2022-07-19 11:00:35 +01:00
TestPThreadPriority.cpp Tests: Add pthread scheduler priority tests 2022-10-27 11:30:19 +01:00
TestPthreadRWLocks.cpp Tests: Move the LibPthread tests to the correct namespace 2022-07-19 11:00:35 +01:00
TestPthreadSpinLocks.cpp Tests: Move the LibPthread tests to the correct namespace 2022-07-19 11:00:35 +01:00
TestPwd.cpp AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
TestQsort.cpp Tests: Use AK::shuffle() for shuffling 2023-01-20 17:45:33 +00:00
TestRaise.cpp
TestRealpath.cpp AK: Remove StringBuilder::build() in favor of to_deprecated_string() 2023-01-27 20:38:49 +00:00
TestScanf.cpp Everywhere: Remove unused includes of LibC/stdlib.h 2023-01-02 20:27:20 -05:00
TestSearch.cpp Everywhere: Remove unused includes of AK/Format.h 2023-01-02 20:27:20 -05:00
TestSnprintf.cpp AK+Everywhere: Change AK::fill_with_random to accept a Bytes object 2023-04-03 15:53:49 +02:00
TestStackSmash.cpp
TestStdio.cpp Tests: Move sprintf test from AK/ to LibC/ 2022-07-04 21:46:02 +02:00
TestStrlcpy.cpp AK+Everywhere: Change AK::fill_with_random to accept a Bytes object 2023-04-03 15:53:49 +02:00
TestStrtodAccuracy.cpp AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
TestWchar.cpp AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
TestWctype.cpp