Replace VLA envp_dynamic with malloc in fork child exec path

This commit is contained in:
Andrea Mazzoleni 2026-08-05 22:24:28 +02:00
parent 6c85573d12
commit acdf29ac09

View file

@ -859,10 +859,12 @@ int os_script(char** argv, char** envp, const char* run_as_user)
if (envp != NULL) {
int envv_count = 0;
while (envp[envv_count] != NULL) {
envv_count++;
++envv_count;
}
int scrubbed_count = sizeof(envp_scrubbed) / sizeof(envp_scrubbed[0]) - 1;
char* envp_dynamic[scrubbed_count + envv_count + 1];
char** envp_dynamic = malloc((size_t)(scrubbed_count + envv_count + 1) * sizeof(char*));
if (!envp_dynamic)
_exit(126);
for (int i = 0; i < scrubbed_count; ++i) {
envp_dynamic[i] = envp_scrubbed[i];
}