mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix the environment functions not rejecting the empty name.
Found by musl's libc-test.
This commit is contained in:
parent
0adfceef87
commit
40fd0fa3dc
3 changed files with 9 additions and 0 deletions
|
@ -39,6 +39,9 @@ extern "C" char* getenv(const char* name)
|
|||
if ( !name )
|
||||
return errno = EINVAL, (char*) NULL;
|
||||
|
||||
if ( !name[0] )
|
||||
return errno = EINVAL, (char*) NULL;
|
||||
|
||||
// Verify the name doesn't contain a '=' character.
|
||||
size_t name_length = 0;
|
||||
while ( name[name_length] )
|
||||
|
|
|
@ -117,6 +117,9 @@ extern "C" int setenv(const char* name, const char* value, int overwrite)
|
|||
if ( !name || !value )
|
||||
return errno = EINVAL, -1;
|
||||
|
||||
if ( !name[0] )
|
||||
return errno = EINVAL, -1;
|
||||
|
||||
// Verify the name doesn't contain a '=' character.
|
||||
size_t name_length = 0;
|
||||
while ( name[name_length] )
|
||||
|
|
|
@ -39,6 +39,9 @@ extern "C" int unsetenv(const char* name)
|
|||
if ( !name )
|
||||
return errno = EINVAL, -1;
|
||||
|
||||
if ( !name[0] )
|
||||
return errno = EINVAL, -1;
|
||||
|
||||
// Verify the name doesn't contain a '=' character.
|
||||
size_t name_length = 0;
|
||||
while ( name[name_length] )
|
||||
|
|
Loading…
Add table
Reference in a new issue