summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjvoisin2017-11-06 14:24:24 +0100
committerblotus2017-11-06 14:24:24 +0100
commit8070f622122344ae52b55c3f80e43a1733ae59e2 (patch)
treec117f5a2a27efb04a4161c2809b26641a2fec0e4 /src
parent27876d63eecbac187921dcf9e8ab2b3341302c05 (diff)
53 absolute path (#62)
* Add error for relative path
Diffstat (limited to 'src')
-rw-r--r--src/sp_config_keywords.c9
-rw-r--r--src/tests/broken_conf_invalid_filename.phpt9
-rw-r--r--src/tests/config/broken_conf_invalid_filename.ini1
-rw-r--r--src/tests/config/config_disabled_functions_param_allow.ini2
-rw-r--r--src/tests/config/disabled_functions.ini2
5 files changed, 19 insertions, 4 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c
index b1b22b5..34b855a 100644
--- a/src/sp_config_keywords.c
+++ b/src/sp_config_keywords.c
@@ -197,7 +197,7 @@ int parse_disabled_functions(char *line) {
197 MUTUALLY_EXCLUSIVE(df->ret, df->r_ret, "r_ret", "ret"); 197 MUTUALLY_EXCLUSIVE(df->ret, df->r_ret, "r_ret", "ret");
198#undef MUTUALLY_EXCLUSIVE 198#undef MUTUALLY_EXCLUSIVE
199 199
200 if (1 < ((df->r_param?1:0) + (df->param?1:0) + ((-1 != df->pos)?1:0))) { 200 if (1 < ((df->r_param?1:0) + (df->param?1:0) + ((-1 != df->pos)?1:0))) {
201 sp_log_err("config", 201 sp_log_err("config",
202 "Invalid configuration line: 'sp.disabled_functions%s':" 202 "Invalid configuration line: 'sp.disabled_functions%s':"
203 "'.r_param', '.param' and '.pos' are mutually exclusive on line %zu.", 203 "'.r_param', '.param' and '.pos' are mutually exclusive on line %zu.",
@@ -215,6 +215,12 @@ int parse_disabled_functions(char *line) {
215 " must take a function name on line %zu.", 215 " must take a function name on line %zu.",
216 line, sp_line_no); 216 line, sp_line_no);
217 return -1; 217 return -1;
218 } else if (df->filename && *df->filename != '/') {
219 sp_log_err("config",
220 "Invalid configuration line: 'sp.disabled_functions%s':"
221 "'.filename' must be an absolute path on line %zu.",
222 line, sp_line_no);
223 return -1;
218 } else if (!(allow ^ drop)) { 224 } else if (!(allow ^ drop)) {
219 sp_log_err("config", 225 sp_log_err("config",
220 "Invalid configuration line: 'sp.disabled_functions%s': The " 226 "Invalid configuration line: 'sp.disabled_functions%s': The "
@@ -244,7 +250,6 @@ int parse_disabled_functions(char *line) {
244 return -1; 250 return -1;
245 } 251 }
246 } 252 }
247
248 df->allow = allow; 253 df->allow = allow;
249 254
250 if (df->function) { 255 if (df->function) {
diff --git a/src/tests/broken_conf_invalid_filename.phpt b/src/tests/broken_conf_invalid_filename.phpt
new file mode 100644
index 0000000..61b967b
--- /dev/null
+++ b/src/tests/broken_conf_invalid_filename.phpt
@@ -0,0 +1,9 @@
1--TEST--
2Broken configuration filename without absolute path
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/broken_conf_invalid_filename.ini
7--FILE--
8--EXPECTF--
9[snuffleupagus][0.0.0.0][config][error] Invalid configuration line: 'sp.disabled_functions.function("sprintf").filename("wrong file name").drop();':'.filename' must be an absolute path on line 1.
diff --git a/src/tests/config/broken_conf_invalid_filename.ini b/src/tests/config/broken_conf_invalid_filename.ini
new file mode 100644
index 0000000..1be3b51
--- /dev/null
+++ b/src/tests/config/broken_conf_invalid_filename.ini
@@ -0,0 +1 @@
sp.disable_function.function("sprintf").filename("wrong file name").drop();
diff --git a/src/tests/config/config_disabled_functions_param_allow.ini b/src/tests/config/config_disabled_functions_param_allow.ini
index aa86f52..8e139e4 100644
--- a/src/tests/config/config_disabled_functions_param_allow.ini
+++ b/src/tests/config/config_disabled_functions_param_allow.ini
@@ -1,3 +1,3 @@
1sp.disable_function.function("system").param("command").value("echo win").filename("test.php").drop(); 1sp.disable_function.function("system").param("command").value("echo win").filename("/test.php").drop();
2sp.disable_function.function("system").param("command").value("echo win").allow(); 2sp.disable_function.function("system").param("command").value("echo win").allow();
3sp.disable_function.function("system").drop(); 3sp.disable_function.function("system").drop();
diff --git a/src/tests/config/disabled_functions.ini b/src/tests/config/disabled_functions.ini
index 18aab27..226a107 100644
--- a/src/tests/config/disabled_functions.ini
+++ b/src/tests/config/disabled_functions.ini
@@ -4,5 +4,5 @@ sp.disable_function.function("printf").disable().drop();
4sp.disable_function.function("printf").simulation().drop(); 4sp.disable_function.function("printf").simulation().drop();
5sp.disable_function.function("print").disable().drop(); # this is a comment 5sp.disable_function.function("print").disable().drop(); # this is a comment
6sp.disable_function.function_r("^var_dump$").drop(); 6sp.disable_function.function_r("^var_dump$").drop();
7sp.disable_function.function("sprintf").filename("wrong file name").drop(); 7sp.disable_function.function("sprintf").filename("/wrong file name").drop();
8sp.disable_function.function("eval").drop(); 8sp.disable_function.function("eval").drop();