diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2020-02-09 04:44:35 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2020-02-09 05:03:37 +0700 |
commit | d419f652bbf282bbb6353429261776d6293fcfb6 (patch) | |
tree | 16ec75985c65a9fdf7e5f803aa06c8007ce2de30 /src | |
parent | 775a6b0ddd0f650febf51a50507c76e021fa543f (diff) |
exec: prevent uninitialized memory access in osmo_system_nowait()
If (!env_whitelist && addl_env), osmo_environment_append() would
access uninitialized memory. If both are false, execle() would
also deal with garbage values. Let's ensure that at least the
first element of new_env[] is initialized.
Change-Id: Id3901de4692ef44e9e9c67b1804e027fc4ce7c18
Fixes: CID#206571
Diffstat (limited to 'src')
-rw-r--r-- | src/exec.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -217,6 +217,9 @@ int osmo_system_nowait(const char *command, const char **env_whitelist, char **a /* close all file descriptors above stdio */ osmo_close_all_fds_above(2); + /* man execle: "an array of pointers *must* be terminated by a null pointer" */ + new_env[0] = NULL; + /* build the new environment */ if (env_whitelist) osmo_environment_filter(new_env, ARRAY_SIZE(new_env), environ, env_whitelist); |