summaryrefslogtreecommitdiff
path: root/src/tests/elua
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-06-09 14:01:25 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-06-09 14:01:25 +0100
commitb90c1bf90e67f1838152185dce5a270f3f824f6b (patch)
tree0255638c4cc55bb616076c3d72b616c875602bc4 /src/tests/elua
parent6692319c7873e0fbb797f01bc2ca41c2d12824b4 (diff)
elua lib: sanitize all file paths before writing them
This will prevent random nonsense from being written in. It changes semantics slightly (documented) and also fixes CID 1267463. @fix
Diffstat (limited to 'src/tests/elua')
-rw-r--r--src/tests/elua/elua_lib.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/tests/elua/elua_lib.c b/src/tests/elua/elua_lib.c
index bd959ca7b1..43df108113 100644
--- a/src/tests/elua/elua_lib.c
+++ b/src/tests/elua/elua_lib.c
@@ -22,6 +22,7 @@ START_TEST(elua_api)
22 int quit = 0; 22 int quit = 0;
23 cargv[0] = arg1; 23 cargv[0] = arg1;
24 cargv[1] = arg2; 24 cargv[1] = arg2;
25 char *spath = NULL;
25 26
26 fail_if(!elua_init()); 27 fail_if(!elua_init());
27 28
@@ -33,18 +34,31 @@ START_TEST(elua_api)
33 setenv("ELUA_MODULES_DIR", "bar", 1); 34 setenv("ELUA_MODULES_DIR", "bar", 1);
34 setenv("ELUA_APPS_DIR", "baz", 1); 35 setenv("ELUA_APPS_DIR", "baz", 1);
35 elua_state_dirs_fill(st, EINA_FALSE); 36 elua_state_dirs_fill(st, EINA_FALSE);
36 fail_if(strcmp(elua_state_core_dir_get(st), "foo")); 37
37 fail_if(strcmp(elua_state_mod_dir_get(st), "bar")); 38 spath = eina_file_path_sanitize("foo");
38 fail_if(strcmp(elua_state_apps_dir_get(st), "baz")); 39 fail_if(strcmp(elua_state_core_dir_get(st), spath));
40 free(spath);
41 spath = eina_file_path_sanitize("bar");
42 fail_if(strcmp(elua_state_mod_dir_get(st), spath));
43 free(spath);
44 spath = eina_file_path_sanitize("baz");
45 fail_if(strcmp(elua_state_apps_dir_get(st), spath));
46 free(spath);
39 unsetenv("ELUA_CORE_DIR"); 47 unsetenv("ELUA_CORE_DIR");
40 unsetenv("ELUA_MODULES_DIR"); 48 unsetenv("ELUA_MODULES_DIR");
41 unsetenv("ELUA_APPS_DIR"); 49 unsetenv("ELUA_APPS_DIR");
42 50
43 /* now fill it properly */ 51 /* now fill it properly */
44 elua_state_dirs_set(st, ELUA_CORE_DIR, ELUA_MODULES_DIR, ELUA_APPS_DIR); 52 elua_state_dirs_set(st, ELUA_CORE_DIR, ELUA_MODULES_DIR, ELUA_APPS_DIR);
45 fail_if(strcmp(elua_state_core_dir_get(st), ELUA_CORE_DIR)); 53 spath = eina_file_path_sanitize(ELUA_CORE_DIR);
46 fail_if(strcmp(elua_state_mod_dir_get(st), ELUA_MODULES_DIR)); 54 fail_if(strcmp(elua_state_core_dir_get(st), spath));
47 fail_if(strcmp(elua_state_apps_dir_get(st), ELUA_APPS_DIR)); 55 free(spath);
56 spath = eina_file_path_sanitize(ELUA_MODULES_DIR);
57 fail_if(strcmp(elua_state_mod_dir_get(st), spath));
58 free(spath);
59 spath = eina_file_path_sanitize(ELUA_APPS_DIR);
60 fail_if(strcmp(elua_state_apps_dir_get(st), spath));
61 free(spath);
48 62
49 /* needed for later setup, but untestable alone */ 63 /* needed for later setup, but untestable alone */
50 elua_state_include_path_add(st, ELUA_BINDINGS_DIR); 64 elua_state_include_path_add(st, ELUA_BINDINGS_DIR);