mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-03 05:10:16 -05:00
Replace VLA envp_dynamic with malloc in fork child exec path
This commit is contained in:
parent
d47a7fa6ff
commit
ae1fe46ea8
1 changed files with 4 additions and 2 deletions
|
|
@ -859,10 +859,12 @@ int os_script(char** argv, char** envp, const char* run_as_user)
|
||||||
if (envp != NULL) {
|
if (envp != NULL) {
|
||||||
int envv_count = 0;
|
int envv_count = 0;
|
||||||
while (envp[envv_count] != NULL) {
|
while (envp[envv_count] != NULL) {
|
||||||
envv_count++;
|
++envv_count;
|
||||||
}
|
}
|
||||||
int scrubbed_count = sizeof(envp_scrubbed) / sizeof(envp_scrubbed[0]) - 1;
|
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) {
|
for (int i = 0; i < scrubbed_count; ++i) {
|
||||||
envp_dynamic[i] = envp_scrubbed[i];
|
envp_dynamic[i] = envp_scrubbed[i];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue