From acdf29ac09f3dbb13e71591fe805f7226d27b43a Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Wed, 5 Aug 2026 22:24:28 +0200 Subject: [PATCH] Replace VLA envp_dynamic with malloc in fork child exec path --- os/unix.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/os/unix.c b/os/unix.c index e575f895..dfc4f053 100644 --- a/os/unix.c +++ b/os/unix.c @@ -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]; }