@@ -1051,7 +1051,7 @@ pseudo_setupenvp(char * const *envp) {
free(pseudo_get_libdir());
free(pseudo_get_localstatedir());
- for (i = 0; envp[i]; ++i) {
+ for (i = 0; envp && envp[i]; ++i) {
if (STARTSWITH(envp[i], PRELINK_LIBRARIES "=")) {
ld_preload = envp[i];
}
@@ -1113,7 +1113,7 @@ pseudo_setupenvp(char * const *envp) {
free(libdir_path);
- for (i = 0; envp[i]; ++i) {
+ for (i = 0; envp && envp[i]; ++i) {
if (STARTSWITH(envp[i], PRELINK_LIBRARIES "=")) continue;
if (STARTSWITH(envp[i], PRELINK_PATH "=")) continue;
new_envp[j++] = envp[i];
Whilst not recommended, the kernel does accept NULL values for envp when passed to execve and posix_spawn. Avoid pseudo_setupenvp segfaulting when such a value is passed in and instead handle it correctly. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> --- pseudo_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)