From ba011051addc98306d701ffa99bc19882cd23356 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 4f53e7d..bcf1b26 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); -- 2.7.4