@@ -38,7 +38,7 @@ static apr_status_t msre_parse_targets(msre_ruleset *ruleset, const char *text,
3838static char * msre_generate_target_string (apr_pool_t * pool ,msre_rule * rule );
3939static msre_var * msre_create_var (msre_ruleset * ruleset ,const char * name ,const char * param ,
4040modsec_rec * msr ,char * * error_msg );
41- static msre_action * msre_create_action (msre_engine * engine ,const char * name ,
41+ static msre_action * msre_create_action (msre_engine * engine ,apr_pool_t * mp , const char * name ,
4242const char * param ,char * * error_msg );
4343static apr_status_t msre_rule_process (msre_rule * rule ,modsec_rec * msr );
4444
@@ -769,7 +769,7 @@ static apr_status_t msre_parse_targets(msre_ruleset *ruleset, const char *text,
769769 * Creates msre_action instances by parsing the given string, placing
770770 * them into the supplied array.
771771 */
772- static apr_status_t msre_parse_actions (msre_engine * engine ,msre_actionset * actionset ,
772+ static apr_status_t msre_parse_actions (msre_engine * engine ,apr_pool_t * mp , msre_actionset * actionset ,
773773const char * text ,char * * error_msg )
774774{
775775const apr_array_header_t * tarr ;
@@ -788,23 +788,23 @@ static apr_status_t msre_parse_actions(msre_engine *engine, msre_actionset *acti
788788
789789
790790if (text == NULL ) {
791- * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
791+ * error_msg = apr_psprintf (mp ,"Internal error: " \
792792"msre_parse_actions, variable text is NULL" );
793793return -1 ;
794794 }
795795
796796/* Extract name & value pairs first */
797- vartable = apr_table_make (engine -> mp ,10 );
797+ vartable = apr_table_make (mp ,10 );
798798if (vartable == NULL ) {
799- * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
799+ * error_msg = apr_psprintf (mp ,"Internal error: " \
800800"msre_parse_actions, failed to create vartable" );
801801
802802return -1 ;
803803 }
804- rc = msre_parse_generic (engine -> mp ,text ,vartable ,error_msg );
804+ rc = msre_parse_generic (mp ,text ,vartable ,error_msg );
805805if (rc < 0 ) {
806806if (* error_msg == NULL )
807- * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
807+ * error_msg = apr_psprintf (mp ,"Internal error: " \
808808"msre_parse_actions, msre_parse_generic failed. Return " \
809809"code: %d" ,rc );
810810
@@ -816,17 +816,17 @@ static apr_status_t msre_parse_actions(msre_engine *engine, msre_actionset *acti
816816telts = (const apr_table_entry_t * )tarr -> elts ;
817817for (i = 0 ;i < tarr -> nelts ;i ++ ) {
818818/* Create action. */
819- action = msre_create_action (engine ,telts [i ].key ,telts [i ].val ,error_msg );
819+ action = msre_create_action (engine ,mp , telts [i ].key ,telts [i ].val ,error_msg );
820820if (action == NULL ) {
821821if (* error_msg == NULL )
822- * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
822+ * error_msg = apr_psprintf (mp ,"Internal error: " \
823823"msre_parse_actions, msre_create_action failed." );
824824return -1 ;
825825 }
826826
827827/* Initialise action (option). */
828828if (action -> metadata -> init != NULL ) {
829- action -> metadata -> init (engine ,actionset ,action );
829+ action -> metadata -> init (engine ,mp , actionset ,action );
830830 }
831831
832832msre_actionset_action_add (actionset ,action );
@@ -895,14 +895,14 @@ msre_var *msre_create_var_ex(apr_pool_t *pool, msre_engine *engine, const char *
895895/* Resolve variable */
896896var -> metadata = msre_resolve_var (engine ,var -> name );
897897if (var -> metadata == NULL ) {
898- * error_msg = apr_psprintf (engine -> mp ,"Unknown variable: %s" ,name );
898+ * error_msg = apr_psprintf (pool ,"Unknown variable: %s" ,name );
899899return NULL ;
900900 }
901901
902902/* The counting operator "&" can only be used against collections. */
903903if (var -> is_counting ) {
904904if (var -> metadata -> type == VAR_SIMPLE ) {
905- * error_msg = apr_psprintf (engine -> mp ,"The & modificator does not apply to "
905+ * error_msg = apr_psprintf (pool ,"The & modificator does not apply to "
906906"non-collection variables." );
907907return NULL ;
908908 }
@@ -911,15 +911,15 @@ msre_var *msre_create_var_ex(apr_pool_t *pool, msre_engine *engine, const char *
911911/* Check the parameter. */
912912if (varparam == NULL ) {
913913if (var -> metadata -> argc_min > 0 ) {
914- * error_msg = apr_psprintf (engine -> mp ,"Missing mandatory parameter for variable %s." ,
914+ * error_msg = apr_psprintf (pool ,"Missing mandatory parameter for variable %s." ,
915915name );
916916return NULL ;
917917 }
918918 }else {/* Parameter present */
919919
920920/* Do we allow a parameter? */
921921if (var -> metadata -> argc_max == 0 ) {
922- * error_msg = apr_psprintf (engine -> mp ,"Variable %s does not support parameters." ,
922+ * error_msg = apr_psprintf (pool ,"Variable %s does not support parameters." ,
923923name );
924924return NULL ;
925925 }
@@ -940,7 +940,7 @@ msre_var *msre_create_var_ex(apr_pool_t *pool, msre_engine *engine, const char *
940940static msre_var * msre_create_var (msre_ruleset * ruleset ,const char * name ,const char * param ,
941941modsec_rec * msr ,char * * error_msg )
942942{
943- msre_var * var = msre_create_var_ex (ruleset -> engine -> mp ,ruleset -> engine ,name ,param ,msr ,error_msg );
943+ msre_var * var = msre_create_var_ex (ruleset -> mp ,ruleset -> engine ,name ,param ,msr ,error_msg );
944944if (var == NULL )return NULL ;
945945
946946/* Validate & initialise variable */
@@ -957,7 +957,7 @@ static msre_var *msre_create_var(msre_ruleset *ruleset, const char *name, const
957957/**
958958 * Creates a new action instance given its name and an (optional) parameter.
959959 */
960- msre_action * msre_create_action (msre_engine * engine ,const char * name ,const char * param ,
960+ msre_action * msre_create_action (msre_engine * engine ,apr_pool_t * mp , const char * name ,const char * param ,
961961char * * error_msg )
962962{
963963msre_action * action = NULL ;
@@ -968,10 +968,10 @@ msre_action *msre_create_action(msre_engine *engine, const char *name, const cha
968968* error_msg = NULL ;
969969
970970
971- action = apr_pcalloc (engine -> mp ,sizeof (msre_action ));
971+ action = apr_pcalloc (mp ,sizeof (msre_action ));
972972
973973if (action == NULL ) {
974- * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
974+ * error_msg = apr_psprintf (mp ,"Internal error: " \
975975"msre_create_action, not able to allocate action" );
976976
977977return NULL ;
@@ -980,28 +980,28 @@ msre_action *msre_create_action(msre_engine *engine, const char *name, const cha
980980/* Resolve action */
981981action -> metadata = msre_resolve_action (engine ,name );
982982if (action -> metadata == NULL ) {
983- * error_msg = apr_psprintf (engine -> mp ,"Unknown action: %s" ,name );
983+ * error_msg = apr_psprintf (mp ,"Unknown action: %s" ,name );
984984return NULL ;
985985 }
986986
987987if (param == NULL ) {/* Parameter not present */
988988if (action -> metadata -> argc_min > 0 ) {
989- * error_msg = apr_psprintf (engine -> mp ,"Missing mandatory parameter for action %s" ,
989+ * error_msg = apr_psprintf (mp ,"Missing mandatory parameter for action %s" ,
990990name );
991991return NULL ;
992992 }
993993 }else {/* Parameter present */
994994
995995/* Should we allow the parameter? */
996996if (action -> metadata -> argc_max == 0 ) {
997- * error_msg = apr_psprintf (engine -> mp ,"Extra parameter provided to action %s" ,name );
997+ * error_msg = apr_psprintf (mp ,"Extra parameter provided to action %s" ,name );
998998return NULL ;
999999 }
10001000
10011001/* Handle +/- modificators */
10021002if ((param [0 ]== '+' )|| (param [0 ]== '-' )) {
10031003if (action -> metadata -> allow_param_plusminus == 0 ) {
1004- * error_msg = apr_psprintf (engine -> mp ,
1004+ * error_msg = apr_psprintf (mp ,
10051005"Action %s does not allow +/- modificators." ,name );
10061006return NULL ;
10071007 }
@@ -1021,7 +1021,7 @@ msre_action *msre_create_action(msre_engine *engine, const char *name, const cha
10211021
10221022/* Validate parameter */
10231023if (action -> metadata -> validate != NULL ) {
1024- * error_msg = action -> metadata -> validate (engine ,action );
1024+ * error_msg = action -> metadata -> validate (engine ,mp , action );
10251025if (* error_msg != NULL )return NULL ;
10261026 }
10271027 }
@@ -1164,7 +1164,7 @@ int msre_parse_generic(apr_pool_t *mp, const char *text, apr_table_t *vartable,
11641164 * Creates an actionset instance and (as an option) populates it by
11651165 * parsing the given string which contains a list of actions.
11661166 */
1167- msre_actionset * msre_actionset_create (msre_engine * engine ,const char * text ,
1167+ msre_actionset * msre_actionset_create (msre_engine * engine ,apr_pool_t * mp , const char * text ,
11681168char * * error_msg )
11691169{
11701170msre_actionset * actionset = NULL ;
@@ -1175,18 +1175,18 @@ msre_actionset *msre_actionset_create(msre_engine *engine, const char *text,
11751175
11761176* error_msg = NULL ;
11771177
1178- actionset = (msre_actionset * )apr_pcalloc (engine -> mp ,
1178+ actionset = (msre_actionset * )apr_pcalloc (mp ,
11791179sizeof (msre_actionset ));
11801180
11811181if (actionset == NULL ) {
1182- * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
1182+ * error_msg = apr_psprintf (mp ,"Internal error: " \
11831183"msre_actionset_create, not able to allocate msre_actionset" );
11841184return NULL ;
11851185 }
11861186
1187- actionset -> actions = apr_table_make (engine -> mp ,25 );
1187+ actionset -> actions = apr_table_make (mp ,25 );
11881188if (actionset -> actions == NULL ) {
1189- * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
1189+ * error_msg = apr_psprintf (mp ,"Internal error: " \
11901190"msre_actionset_create, not able to create actions table" );
11911191return NULL ;
11921192 }
@@ -1225,10 +1225,10 @@ msre_actionset *msre_actionset_create(msre_engine *engine, const char *text,
12251225
12261226/* Parse the list of actions, if it's present */
12271227if (text != NULL ) {
1228- int ret = msre_parse_actions (engine ,actionset ,text ,error_msg );
1228+ int ret = msre_parse_actions (engine ,mp , actionset ,text ,error_msg );
12291229if (ret < 0 ) {
1230- if (* error_msg == NULL )
1231- * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
1230+ if (* error_msg == NULL )
1231+ * error_msg = apr_psprintf (mp ,"Internal error: " \
12321232"msre_actionset_create, msre_parse_actions failed " \
12331233"without further information. Return code: %d" ,ret );
12341234return NULL ;
@@ -1255,7 +1255,7 @@ static msre_actionset *msre_actionset_copy(apr_pool_t *mp, msre_actionset *orig)
12551255/**
12561256 * Merges two actionsets into one.
12571257 */
1258- msre_actionset * msre_actionset_merge (msre_engine * engine ,msre_actionset * parent ,
1258+ msre_actionset * msre_actionset_merge (msre_engine * engine ,apr_pool_t * mp , msre_actionset * parent ,
12591259msre_actionset * child ,int inherit_by_default )
12601260{
12611261msre_actionset * merged = NULL ;
@@ -1265,11 +1265,11 @@ msre_actionset *msre_actionset_merge(msre_engine *engine, msre_actionset *parent
12651265
12661266if (inherit_by_default == 0 ) {
12671267/* There is nothing to merge in this case. */
1268- return msre_actionset_copy (engine -> mp ,child );
1268+ return msre_actionset_copy (mp ,child );
12691269 }
12701270
12711271/* Start with a copy of the parent configuration. */
1272- merged = msre_actionset_copy (engine -> mp ,parent );
1272+ merged = msre_actionset_copy (mp ,parent );
12731273if (merged == NULL )return NULL ;
12741274
12751275if (child == NULL ) {
@@ -1332,6 +1332,7 @@ msre_actionset *msre_actionset_merge(msre_engine *engine, msre_actionset *parent
13321332msre_actionset * msre_actionset_create_default (msre_engine * engine ) {
13331333char * my_error_msg = NULL ;
13341334return msre_actionset_create (engine ,
1335+ engine -> mp ,
13351336"phase:2,log,auditlog,pass" ,
13361337& my_error_msg );
13371338}
@@ -2407,7 +2408,7 @@ msre_rule *msre_rule_create(msre_ruleset *ruleset, int type,
24072408/* Parse actions */
24082409if (actions != NULL ) {
24092410/* Create per-rule actionset */
2410- rule -> actionset = msre_actionset_create (ruleset -> engine ,actions ,& my_error_msg );
2411+ rule -> actionset = msre_actionset_create (ruleset -> engine ,ruleset -> mp , actions ,& my_error_msg );
24112412if (rule -> actionset == NULL ) {
24122413* error_msg = apr_psprintf (ruleset -> mp ,"Error parsing actions: %s" ,my_error_msg );
24132414return NULL ;
@@ -2451,7 +2452,7 @@ msre_rule *msre_rule_lua_create(msre_ruleset *ruleset,
24512452/* Parse actions */
24522453if (actions != NULL ) {
24532454/* Create per-rule actionset */
2454- rule -> actionset = msre_actionset_create (ruleset -> engine ,actions ,& my_error_msg );
2455+ rule -> actionset = msre_actionset_create (ruleset -> engine ,ruleset -> mp , actions ,& my_error_msg );
24552456if (rule -> actionset == NULL ) {
24562457* error_msg = apr_psprintf (ruleset -> mp ,"Error parsing actions: %s" ,my_error_msg );
24572458return NULL ;