summaryrefslogtreecommitdiff
path: root/src/tests/elua
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-02-21 15:04:31 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2019-02-21 15:05:22 +0100
commit95d414549b9e6838b7b2d59e105ddf6955aa8d97 (patch)
tree3f011e7b8714589e739c5cee573fdb0ea665339d /src/tests/elua
parent2b86bd0b3e738ecd0c4519d1032d2e2c3fd8636a (diff)
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.
Diffstat (limited to 'src/tests/elua')
-rw-r--r--src/tests/elua/elua_lib.c6
1 files changed, 6 insertions, 0 deletions
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 @@
4 4
5#include <stdlib.h> 5#include <stdlib.h>
6#include <stdio.h> 6#include <stdio.h>
7#include <unistd.h>
7 8
8#include <Eina.h> 9#include <Eina.h>
9#include <Elua.h> 10#include <Elua.h>
@@ -28,6 +29,11 @@ EFL_START_TEST(elua_api)
28 st = elua_state_new("test"); 29 st = elua_state_new("test");
29 fail_if(!st); 30 fail_if(!st);
30 31
32 /* elua APIs here try accessing files by relative path,
33 * prevent any unintentional file accesses in cwd
34 */
35 fail_if(chdir(TESTS_SRC_DIR));
36
31 /* test env vars */ 37 /* test env vars */
32 setenv("ELUA_CORE_DIR", "foo", 1); 38 setenv("ELUA_CORE_DIR", "foo", 1);
33 setenv("ELUA_MODULES_DIR", "bar", 1); 39 setenv("ELUA_MODULES_DIR", "bar", 1);