aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2017-01-20 00:45:09 +0530
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2017-01-20 00:45:09 +0530
commit41389c40499a083c59e68ba281ec87be567f2871 (patch)
tree4d5ff86fc8a5216850383149fbe35944c32adb69 /elf
parent3a66b2b0637e439fb0e7a14c6c3d4c58190eec61 (diff)
downloadglibc-41389c40499a083c59e68ba281ec87be567f2871.tar
glibc-41389c40499a083c59e68ba281ec87be567f2871.tar.gz
glibc-41389c40499a083c59e68ba281ec87be567f2871.tar.bz2
glibc-41389c40499a083c59e68ba281ec87be567f2871.zip
Fix environment traversal when an envvar value is empty
The condition when the value of an envvar is empty (not just '\0'), the loop in tunables_init gets stuck infinitely because envp is not incremented. Fix that by always incrementing envp in the loop. Added test case (tst-empty-env.c) verifies the fix when the source is configured with --enable-hardcoded-path-in-tests, thanks Josh Stone for providing the test case. Verified on x86_64. * elf/dl-tunables (get_next_env): Always advance envp. * stdlib/tst-empty-env.c: New test case. * stdlib/Makefile (tests): Use it.
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-tunables.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
index e0119d17ed..ba5246a099 100644
--- a/elf/dl-tunables.c
+++ b/elf/dl-tunables.c
@@ -80,7 +80,7 @@ get_next_env (char **envp, char **name, size_t *namelen, char **val)
{
while (envp != NULL && *envp != NULL)
{
- char *envline = *envp;
+ char *envline = *envp++;
int len = 0;
while (envline[len] != '\0' && envline[len] != '=')
@@ -94,7 +94,7 @@ get_next_env (char **envp, char **name, size_t *namelen, char **val)
*namelen = len;
*val = &envline[len + 1];
- return ++envp;
+ return envp;
}
return NULL;