From 9a0255c508ede92423a1f8a02c6c38328482c55f Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Thu, 11 Apr 2013 10:00:14 +0200 Subject: Default TEST_DIR to cwd, not empty string if not set explicitly If configure isn't being run with argument --with-test-dir, then variable TEST_DIR will be defined, but its value will be empty (""). In this case opendir will fail with uncatched error "Directory does not exist, or name is an empty string". Finally function call dirfd will segfault because its argument is NULL. I changed default value of TEST_DIR (if --with-test-dir was not used). Function tests_set_cwd does not ignore return value of chdir, because TEST_DIR should not be the empty string. --- src/tests/common.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/tests') diff --git a/src/tests/common.c b/src/tests/common.c index 54c93e281..16c051656 100644 --- a/src/tests/common.c +++ b/src/tests/common.c @@ -33,12 +33,8 @@ tests_set_cwd(void) ret = chdir(TEST_DIR); if (ret == -1) { - if (strlen(TEST_DIR)) { - fprintf(stderr, - "Could not chdir to [%s].\n" - "Attempting to continue with current dir\n", - TEST_DIR); - } + fprintf(stderr, "Could not chdir to [%s].\n" + "Attempting to continue with current dir\n", TEST_DIR); } } -- cgit