Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit31d7fc6

Browse files
author
Felipe Zimmerle
committed
Code cosmetics: Place copy_rules in nice shape.
Continuation of kukackajiri's work to provide fixes for errors pointed byParfait. The function copy_rules had an integer as return code but it was notfiled proper neither checked by its callers. This commit just adds sanitychecks and documentation for the copy_rules function. Marking were placedon the copy_rules callers, but the return code is not handled yet.For kukackajiri's work, see merge request:owasp-modsecurity#612
1 parent62a6f22 commit31d7fc6

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

‎apache2/apache2_config.c‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,31 @@ static void copy_rules_phase(apr_pool_t *mp,
256256
}
257257

258258
/**
259-
* Copies rules between two configuration contexts,
259+
* @brief Copies rules between one phase of two configuration contexts.
260+
*
261+
* Copies rules between one phase of two configuration contexts,
260262
* taking exceptions into account.
263+
*
264+
* @param mp apr pool structure
265+
* @param parent_ruleset Parent's msre_ruleset
266+
* @param child_ruleset Child's msre_ruleset
267+
* @param exceptions_arr Exceptions' apr_array_header_t
268+
* @retval 0 Everything went well.
269+
* @retval -1 Something went wrong.
270+
*
261271
*/
262272
staticintcopy_rules(apr_pool_t*mp,msre_ruleset*parent_ruleset,
263273
msre_ruleset*child_ruleset,
264274
apr_array_header_t*exceptions_arr)
265275
{
276+
intret=0;
277+
278+
if (parent_ruleset==NULL||child_ruleset==NULL||
279+
exceptions_arr==NULL) {
280+
ret=-1;
281+
gotofailed;
282+
}
283+
266284
copy_rules_phase(mp,parent_ruleset->phase_request_headers,
267285
child_ruleset->phase_request_headers,exceptions_arr);
268286
copy_rules_phase(mp,parent_ruleset->phase_request_body,
@@ -274,7 +292,8 @@ static int copy_rules(apr_pool_t *mp, msre_ruleset *parent_ruleset,
274292
copy_rules_phase(mp,parent_ruleset->phase_logging,
275293
child_ruleset->phase_logging,exceptions_arr);
276294

277-
return1;
295+
failed:
296+
returnret;
278297
}
279298

280299
/**
@@ -393,6 +412,7 @@ void *merge_directory_configs(apr_pool_t *mp, void *_parent, void *_child)
393412

394413
/* Copy the rules from the parent context. */
395414
merged->ruleset=msre_ruleset_create(parent->ruleset->engine,mp);
415+
/* TODO: copy_rules return code should be taken into consideration. */
396416
copy_rules(mp,parent->ruleset,merged->ruleset,child->rule_exceptions);
397417
}else
398418
if (parent->ruleset==NULL) {
@@ -419,6 +439,7 @@ void *merge_directory_configs(apr_pool_t *mp, void *_parent, void *_child)
419439

420440
/* Copy parent rules, then add child rules to it. */
421441
merged->ruleset=msre_ruleset_create(parent->ruleset->engine,mp);
442+
/* TODO: copy_rules return code should be taken into consideration. */
422443
copy_rules(mp,parent->ruleset,merged->ruleset,child->rule_exceptions);
423444

424445
apr_array_cat(merged->ruleset->phase_request_headers,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp