From 41389c40499a083c59e68ba281ec87be567f2871 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Fri, 20 Jan 2017 00:45:09 +0530 Subject: 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. --- stdlib/Makefile | 3 +++ 1 file changed, 3 insertions(+) (limited to 'stdlib/Makefile') diff --git a/stdlib/Makefile b/stdlib/Makefile index 0c099733fe..5751b5d600 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -81,6 +81,9 @@ tests := tst-strtol tst-strtod testmb testrand testsort testdiv \ tst-quick_exit tst-thread-quick_exit tst-width \ tst-width-stdint tst-strfrom tst-strfrom-locale \ tst-getrandom +ifeq ($(build-hardcoded-path-in-tests),yes) +tests += tst-empty-env +endif tests-static := tst-secure-getenv ifeq ($(have-cxx-thread_local),yes) CFLAGS-tst-quick_exit.o = -std=c++11 -- cgit 1.4.1