1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:14:58 +00:00

LibCore+LibC: Add putenv() wrapper

This is made safe with a special serenity_putenv() function in LibC.
This commit is contained in:
MacDue 2023-02-04 15:44:33 +00:00 committed by Andreas Kling
parent f4236e61bf
commit eea4dc5bfe
4 changed files with 24 additions and 0 deletions

View file

@ -486,6 +486,14 @@ int serenity_setenv(char const* name, ssize_t name_length, char const* value, ss
return putenv(var);
}
// A non-evil version of putenv that will strdup the env (and free it later)
int serenity_putenv(char const* new_var, size_t length)
{
auto* var = strndup(new_var, length);
s_malloced_environment_variables.set((FlatPtr)var);
return putenv(var);
}
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/putenv.html
int putenv(char* new_var)
{