diff options
| author | Ben Fuhrmannek | 2020-06-15 11:33:48 +0200 |
|---|---|---|
| committer | Ben Fuhrmannek | 2020-06-15 11:33:48 +0200 |
| commit | d8bf25aa20e93d366133b4550ac8304d06186ad3 (patch) | |
| tree | 710b79e39a3d45528726d0bfd63c5f80f7d8d819 /src | |
| parent | 8776410692bf336a104fa19442f0fb761ecf0b5d (diff) | |
stricter config checks
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp_config_keywords.c | 64 |
1 files changed, 20 insertions, 44 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c index abb3110..5f6cc7b 100644 --- a/src/sp_config_keywords.c +++ b/src/sp_config_keywords.c | |||
| @@ -356,65 +356,41 @@ int parse_disabled_functions(char *line) { | |||
| 356 | "Invalid configuration line: 'sp.disabled_functions%s': " \ | 356 | "Invalid configuration line: 'sp.disabled_functions%s': " \ |
| 357 | "'.%s' and '.%s' are mutually exclusive on line %zu", \ | 357 | "'.%s' and '.%s' are mutually exclusive on line %zu", \ |
| 358 | line, STR1, STR2, sp_line_no); \ | 358 | line, STR1, STR2, sp_line_no); \ |
| 359 | return 1; \ | 359 | return -1; \ |
| 360 | } | 360 | } |
| 361 | 361 | ||
| 362 | MUTUALLY_EXCLUSIVE(df->value, df->r_value, "value", "regexp"); | 362 | MUTUALLY_EXCLUSIVE(df->value, df->r_value, "value", "value_r"); |
| 363 | MUTUALLY_EXCLUSIVE(df->r_function, df->function, "r_function", "function"); | 363 | MUTUALLY_EXCLUSIVE(df->r_function, df->function, "function", "function_r"); |
| 364 | MUTUALLY_EXCLUSIVE(df->filename, df->r_filename, "r_filename", "filename"); | 364 | MUTUALLY_EXCLUSIVE(df->filename, df->r_filename, "filename", "filename_r"); |
| 365 | MUTUALLY_EXCLUSIVE(df->ret, df->r_ret, "r_ret", "ret"); | 365 | MUTUALLY_EXCLUSIVE(df->ret, df->r_ret, "ret", "ret_r"); |
| 366 | MUTUALLY_EXCLUSIVE(df->key, df->r_key, "r_key", "key"); | 366 | MUTUALLY_EXCLUSIVE(df->key, df->r_key, "key", "key_r"); |
| 367 | MUTUALLY_EXCLUSIVE(pos, param, "pos", "param"); | ||
| 368 | MUTUALLY_EXCLUSIVE(pos, df->r_param, "pos", "param_r"); | ||
| 369 | MUTUALLY_EXCLUSIVE(param, df->r_param, "param", "param_r"); | ||
| 370 | MUTUALLY_EXCLUSIVE((df->r_key || df->key), (df->r_value || df->value), "key", "value"); | ||
| 371 | MUTUALLY_EXCLUSIVE((df->r_ret || df->ret || df->ret_type), (df->r_param || param), "ret", "param"); | ||
| 372 | MUTUALLY_EXCLUSIVE((df->r_ret || df->ret || df->ret_type), (var), "ret", "var"); | ||
| 373 | MUTUALLY_EXCLUSIVE((df->r_ret || df->ret || df->ret_type), (df->value || df->r_value), "ret", "value"); | ||
| 374 | |||
| 367 | #undef MUTUALLY_EXCLUSIVE | 375 | #undef MUTUALLY_EXCLUSIVE |
| 368 | 376 | ||
| 369 | if (1 < | 377 | if (!(df->r_function || df->function)) { |
| 370 | ((df->r_param ? 1 : 0) + (param ? 1 : 0) + ((-1 != df->pos) ? 1 : 0))) { | ||
| 371 | sp_log_err( | ||
| 372 | "config", | ||
| 373 | "Invalid configuration line: 'sp.disabled_functions%s':" | ||
| 374 | "'.r_param', '.param' and '.pos' are mutually exclusive on line %zu", | ||
| 375 | line, sp_line_no); | ||
| 376 | return -1; | ||
| 377 | } else if ((df->r_key || df->key) && (df->r_value || df->value)) { | ||
| 378 | sp_log_err("config", | ||
| 379 | "Invalid configuration line: 'sp.disabled_functions%s':" | ||
| 380 | "`key` and `value` are mutually exclusive on line %zu", | ||
| 381 | line, sp_line_no); | ||
| 382 | return -1; | ||
| 383 | } else if ((df->r_ret || df->ret || df->ret_type) && (df->r_param || param)) { | ||
| 384 | sp_log_err("config", | ||
| 385 | "Invalid configuration line: 'sp.disabled_functions%s':" | ||
| 386 | "`ret` and `param` are mutually exclusive on line %zu", | ||
| 387 | line, sp_line_no); | ||
| 388 | return -1; | ||
| 389 | } else if ((df->r_ret || df->ret || df->ret_type) && (var)) { | ||
| 390 | sp_log_err("config", | ||
| 391 | "Invalid configuration line: 'sp.disabled_functions%s':" | ||
| 392 | "`ret` and `var` are mutually exclusive on line %zu", | ||
| 393 | line, sp_line_no); | ||
| 394 | return -1; | ||
| 395 | } else if ((df->r_ret || df->ret || df->ret_type) && | ||
| 396 | (df->value || df->r_value)) { | ||
| 397 | sp_log_err("config", | ||
| 398 | "Invalid configuration line: 'sp.disabled_functions%s':" | ||
| 399 | "`ret` and `value` are mutually exclusive on line %zu", | ||
| 400 | line, sp_line_no); | ||
| 401 | return -1; | ||
| 402 | } else if (!(df->r_function || df->function)) { | ||
| 403 | sp_log_err("config", | 378 | sp_log_err("config", |
| 404 | "Invalid configuration line: 'sp.disabled_functions%s':" | 379 | "Invalid configuration line: 'sp.disabled_functions%s':" |
| 405 | " must take a function name on line %zu", | 380 | " must take a function name on line %zu", |
| 406 | line, sp_line_no); | 381 | line, sp_line_no); |
| 407 | return -1; | 382 | return -1; |
| 408 | } else if (df->filename && (*ZSTR_VAL(df->filename) != '/') && | 383 | } |
| 409 | (0 != | 384 | if (df->filename && (*ZSTR_VAL(df->filename) != '/') && |
| 410 | strncmp(ZSTR_VAL(df->filename), "phar://", strlen("phar://")))) { | 385 | (0 != strncmp(ZSTR_VAL(df->filename), "phar://", strlen("phar://")))) { |
| 411 | sp_log_err( | 386 | sp_log_err( |
| 412 | "config", | 387 | "config", |
| 413 | "Invalid configuration line: 'sp.disabled_functions%s':" | 388 | "Invalid configuration line: 'sp.disabled_functions%s':" |
| 414 | "'.filename' must be an absolute path or a phar archive on line %zu", | 389 | "'.filename' must be an absolute path or a phar archive on line %zu", |
| 415 | line, sp_line_no); | 390 | line, sp_line_no); |
| 416 | return -1; | 391 | return -1; |
| 417 | } else if (!(allow ^ drop)) { | 392 | } |
| 393 | if (!(allow ^ drop)) { | ||
| 418 | sp_log_err("config", | 394 | sp_log_err("config", |
| 419 | "Invalid configuration line: 'sp.disabled_functions%s': The " | 395 | "Invalid configuration line: 'sp.disabled_functions%s': The " |
| 420 | "rule must either be a `drop` or `allow` one on line %zu", | 396 | "rule must either be a `drop` or `allow` one on line %zu", |
