summaryrefslogtreecommitdiff
path: root/src/sp_config_keywords.c
diff options
context:
space:
mode:
authorBen Fuhrmannek2020-06-15 11:33:48 +0200
committerjvoisin2022-03-20 18:09:53 +0100
commitab1154af363065e090f2b2afcf589d140c2f83ea (patch)
tree2410817c2502c5c05b727428936b079860f5bcaa /src/sp_config_keywords.c
parentd94795f7043c3a9615e42f2c2f91ead7967d01f2 (diff)
stricter config checks
Diffstat (limited to 'src/sp_config_keywords.c')
-rw-r--r--src/sp_config_keywords.c53
1 files changed, 14 insertions, 39 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c
index 550900f..325ee6c 100644
--- a/src/sp_config_keywords.c
+++ b/src/sp_config_keywords.c
@@ -378,62 +378,37 @@ int parse_disabled_functions(char *line) {
378 return -1; \ 378 return -1; \
379 } 379 }
380 380
381 MUTUALLY_EXCLUSIVE(df->r_value, df->value, "r_value", "value"); 381 MUTUALLY_EXCLUSIVE(df->r_value, df->value, "r_value", "regexp");
382 MUTUALLY_EXCLUSIVE(df->r_function, df->function, "r_function", "function"); 382 MUTUALLY_EXCLUSIVE(df->r_function, df->function, "r_function", "function");
383 MUTUALLY_EXCLUSIVE(df->r_filename, df->filename, "r_filename", "filename"); 383 MUTUALLY_EXCLUSIVE(df->r_filename, df->filename, "r_filename", "filename");
384 MUTUALLY_EXCLUSIVE(df->r_ret, df->ret, "r_ret", "ret"); 384 MUTUALLY_EXCLUSIVE(df->r_ret, df->ret, "r_ret", "ret");
385 MUTUALLY_EXCLUSIVE(df->r_key, df->key, "r_key", "key"); 385 MUTUALLY_EXCLUSIVE(df->r_key, df->key, "r_key", "key");
386 MUTUALLY_EXCLUSIVE(pos, param, "pos", "param");
387 MUTUALLY_EXCLUSIVE(pos, df->r_param, "pos", "param_r");
388 MUTUALLY_EXCLUSIVE(param, df->r_param, "param", "param_r");
389 MUTUALLY_EXCLUSIVE((df->r_key || df->key), (df->r_value || df->value), "key", "value");
390 MUTUALLY_EXCLUSIVE((df->r_ret || df->ret || df->ret_type), (df->r_param || param), "ret", "param");
391 MUTUALLY_EXCLUSIVE((df->r_ret || df->ret || df->ret_type), (var), "ret", "var");
392 MUTUALLY_EXCLUSIVE((df->r_ret || df->ret || df->ret_type), (df->value || df->r_value), "ret", "value");
386#undef MUTUALLY_EXCLUSIVE 393#undef MUTUALLY_EXCLUSIVE
387 394
388 if (1 < 395 if (!(df->r_function || df->function)) {
389 ((df->r_param ? 1 : 0) + (param ? 1 : 0) + ((-1 != df->pos) ? 1 : 0))) {
390 sp_log_err(
391 "config",
392 "Invalid configuration line: 'sp.disabled_functions%s':"
393 "'.r_param', '.param' and '.pos' are mutually exclusive on line %zu",
394 line, sp_line_no);
395 return -1;
396 } else if ((df->r_key || df->key) && (df->r_value || df->value)) {
397 sp_log_err("config",
398 "Invalid configuration line: 'sp.disabled_functions%s':"
399 "`key` and `value` are mutually exclusive on line %zu",
400 line, sp_line_no);
401 return -1;
402 } else if ((df->r_ret || df->ret || df->ret_type) && (df->r_param || param)) {
403 sp_log_err("config",
404 "Invalid configuration line: 'sp.disabled_functions%s':"
405 "`ret` and `param` are mutually exclusive on line %zu",
406 line, sp_line_no);
407 return -1;
408 } else if ((df->r_ret || df->ret || df->ret_type) && (var)) {
409 sp_log_err("config",
410 "Invalid configuration line: 'sp.disabled_functions%s':"
411 "`ret` and `var` are mutually exclusive on line %zu",
412 line, sp_line_no);
413 return -1;
414 } else if ((df->r_ret || df->ret || df->ret_type) &&
415 (df->value || df->r_value)) {
416 sp_log_err("config",
417 "Invalid configuration line: 'sp.disabled_functions%s':"
418 "`ret` and `value` are mutually exclusive on line %zu",
419 line, sp_line_no);
420 return -1;
421 } else if (!(df->r_function || df->function)) {
422 sp_log_err("config", 396 sp_log_err("config",
423 "Invalid configuration line: 'sp.disabled_functions%s':" 397 "Invalid configuration line: 'sp.disabled_functions%s':"
424 " must take a function name on line %zu", 398 " must take a function name on line %zu",
425 line, sp_line_no); 399 line, sp_line_no);
426 return -1; 400 return -1;
427 } else if (df->filename && (*ZSTR_VAL(df->filename) != '/') && 401 }
428 (0 != 402 if (df->filename && (*ZSTR_VAL(df->filename) != '/') &&
429 strncmp(ZSTR_VAL(df->filename), "phar://", strlen("phar://")))) { 403 (0 != strncmp(ZSTR_VAL(df->filename), "phar://", strlen("phar://")))) {
430 sp_log_err( 404 sp_log_err(
431 "config", 405 "config",
432 "Invalid configuration line: 'sp.disabled_functions%s':" 406 "Invalid configuration line: 'sp.disabled_functions%s':"
433 "'.filename' must be an absolute path or a phar archive on line %zu", 407 "'.filename' must be an absolute path or a phar archive on line %zu",
434 line, sp_line_no); 408 line, sp_line_no);
435 return -1; 409 return -1;
436 } else if (!(allow ^ drop)) { 410 }
411 if (!(allow ^ drop)) {
437 sp_log_err("config", 412 sp_log_err("config",
438 "Invalid configuration line: 'sp.disabled_functions%s': The " 413 "Invalid configuration line: 'sp.disabled_functions%s': The "
439 "rule must either be a `drop` or `allow` one on line %zu", 414 "rule must either be a `drop` or `allow` one on line %zu",