mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibC+LibCore: Remove serenity_setenv()
This was called from LibCore and passed raw StringView data that may not be null terminated, then incorrectly passed those strings to getenv() and also tried printing them with just the %s format specifier.
This commit is contained in:
parent
eea4dc5bfe
commit
b16ec1880c
3 changed files with 11 additions and 15 deletions
|
@ -471,15 +471,10 @@ int clearenv()
|
|||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/setenv.html
|
||||
int setenv(char const* name, char const* value, int overwrite)
|
||||
{
|
||||
return serenity_setenv(name, strlen(name), value, strlen(value), overwrite);
|
||||
}
|
||||
|
||||
int serenity_setenv(char const* name, ssize_t name_length, char const* value, ssize_t value_length, int overwrite)
|
||||
{
|
||||
if (!overwrite && getenv(name))
|
||||
return 0;
|
||||
auto const total_length = name_length + value_length + 2;
|
||||
auto const total_length = strlen(name) + strlen(value) + 2;
|
||||
auto* var = (char*)malloc(total_length);
|
||||
snprintf(var, total_length, "%s=%s", name, value);
|
||||
s_malloced_environment_variables.set((FlatPtr)var);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue