From 95d414549b9e6838b7b2d59e105ddf6955aa8d97 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Thu, 21 Feb 2019 15:04:31 +0100 Subject: [PATCH] tests: add chdir in elua to prevent incorrect file accesses Elua is testing API that tries to read files by path, prevent unintentional reads from current working directory by changing that directory. --- src/tests/elua/elua_lib.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tests/elua/elua_lib.c b/src/tests/elua/elua_lib.c index 4f53e7d869..bcf1b26f90 100644 --- a/src/tests/elua/elua_lib.c +++ b/src/tests/elua/elua_lib.c @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -28,6 +29,11 @@ EFL_START_TEST(elua_api) st = elua_state_new("test"); fail_if(!st); + /* elua APIs here try accessing files by relative path, + * prevent any unintentional file accesses in cwd + */ + fail_if(chdir(TESTS_SRC_DIR)); + /* test env vars */ setenv("ELUA_CORE_DIR", "foo", 1); setenv("ELUA_MODULES_DIR", "bar", 1);