re_operators.c: removed invalid check (done correctly on line 1067)

copy_rules(): only one return code => void
This commit is contained in:
Marc Stern
2024-08-07 09:42:40 +02:00
parent cb11716af7
commit 8dd5d5f46b
2 changed files with 2 additions and 12 deletions

View File

@@ -293,15 +293,14 @@ static void copy_rules_phase(apr_pool_t *mp,
* @retval -1 Something went wrong. * @retval -1 Something went wrong.
* *
*/ */
static int copy_rules(apr_pool_t *mp, msre_ruleset *parent_ruleset, static void copy_rules(apr_pool_t *mp, msre_ruleset *parent_ruleset,
msre_ruleset *child_ruleset, msre_ruleset *child_ruleset,
apr_array_header_t *exceptions_arr) apr_array_header_t *exceptions_arr)
{ {
assert(parent_ruleset != NULL); assert(parent_ruleset != NULL);
assert(child_ruleset != NULL); assert(child_ruleset != NULL);
assert(exceptions_arr != NULL); assert(exceptions_arr != NULL);
int ret = 0;
copy_rules_phase(mp, parent_ruleset->phase_request_headers, copy_rules_phase(mp, parent_ruleset->phase_request_headers,
child_ruleset->phase_request_headers, exceptions_arr); child_ruleset->phase_request_headers, exceptions_arr);
copy_rules_phase(mp, parent_ruleset->phase_request_body, copy_rules_phase(mp, parent_ruleset->phase_request_body,
@@ -312,9 +311,6 @@ static int copy_rules(apr_pool_t *mp, msre_ruleset *parent_ruleset,
child_ruleset->phase_response_body, exceptions_arr); child_ruleset->phase_response_body, exceptions_arr);
copy_rules_phase(mp, parent_ruleset->phase_logging, copy_rules_phase(mp, parent_ruleset->phase_logging,
child_ruleset->phase_logging, exceptions_arr); child_ruleset->phase_logging, exceptions_arr);
failed:
return ret;
} }
/** /**
@@ -439,7 +435,6 @@ void *merge_directory_configs(apr_pool_t *mp, void *_parent, void *_child)
/* Copy the rules from the parent context. */ /* Copy the rules from the parent context. */
merged->ruleset = msre_ruleset_create(parent->ruleset->engine, mp); merged->ruleset = msre_ruleset_create(parent->ruleset->engine, mp);
/* TODO: copy_rules return code should be taken into consideration. */
copy_rules(mp, parent->ruleset, merged->ruleset, child->rule_exceptions); copy_rules(mp, parent->ruleset, merged->ruleset, child->rule_exceptions);
} else } else
if (parent->ruleset == NULL) { if (parent->ruleset == NULL) {
@@ -466,7 +461,6 @@ void *merge_directory_configs(apr_pool_t *mp, void *_parent, void *_child)
/* Copy parent rules, then add child rules to it. */ /* Copy parent rules, then add child rules to it. */
merged->ruleset = msre_ruleset_create(parent->ruleset->engine, mp); merged->ruleset = msre_ruleset_create(parent->ruleset->engine, mp);
/* TODO: copy_rules return code should be taken into consideration. */
copy_rules(mp, parent->ruleset, merged->ruleset, child->rule_exceptions); copy_rules(mp, parent->ruleset, merged->ruleset, child->rule_exceptions);
apr_array_cat(merged->ruleset->phase_request_headers, apr_array_cat(merged->ruleset->phase_request_headers,

View File

@@ -1037,10 +1037,6 @@ static int msre_op_rx_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, c
assert(var != NULL); assert(var != NULL);
assert(error_msg != NULL); assert(error_msg != NULL);
msc_regex_t *regex = (msc_regex_t *)rule->op_param_data; msc_regex_t *regex = (msc_regex_t *)rule->op_param_data;
if (!regex) {
msr_log(msr, 1, "rx: Memory allocation error");
return -1;
}
msc_string *re_pattern = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string)); msc_string *re_pattern = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string));
if (!re_pattern) { if (!re_pattern) {
msr_log(msr, 1, "rx: Memory allocation error"); msr_log(msr, 1, "rx: Memory allocation error");