Skip to content

Commit 039b350

Browse files
lightseyFelipe Zimmerle
authored andcommitted
Fix other usage of the global pool for request temporaries in re_operators.c
1 parent e419b50 commit 039b350

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

apache2/re_operators.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
16841684
return 0;
16851685
}
16861686

1687-
data = apr_pcalloc(rule->ruleset->mp, var->value_len+1);
1687+
data = apr_pcalloc(msr->mp, var->value_len+1);
16881688

16891689
if(data == NULL) {
16901690
*error_msg = "Internal Error: cannot allocate memory for data.";
@@ -1699,18 +1699,18 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
16991699
{
17001700
for(i = 0; i < rv; ++i)
17011701
{
1702-
match = apr_psprintf(rule->ruleset->mp, "%.*s", ovector[2*i+1] - ovector[2*i], data + ovector[2*i]);
1702+
match = apr_psprintf(msr->mp, "%.*s", ovector[2*i+1] - ovector[2*i], data + ovector[2*i]);
17031703

17041704
if (match == NULL) {
17051705
*error_msg = "Internal Error: cannot allocate memory for match.";
17061706
return -1;
17071707
}
17081708

1709-
match = remove_escape(rule->ruleset->mp, match, strlen(match));
1709+
match = remove_escape(msr->mp, match, strlen(match));
17101710

1711-
match = gsb_replace_tpath(rule->ruleset->mp, match, strlen(match));
1711+
match = gsb_replace_tpath(msr->mp, match, strlen(match));
17121712

1713-
match = gsb_reduce_char(rule->ruleset->mp, match);
1713+
match = gsb_reduce_char(msr->mp, match);
17141714

17151715
match_length = strlen(match);
17161716

@@ -1732,7 +1732,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
17321732
log_escape_nq(msr->mp, match));
17331733
}
17341734

1735-
str = apr_pstrdup(rule->ruleset->mp,match);
1735+
str = apr_pstrdup(msr->mp,match);
17361736

17371737
base = apr_strtok(str,"/",&savedptr);
17381738
if(base != NULL)
@@ -1744,7 +1744,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
17441744
/* append / in the end of full url */
17451745
if ((match[match_length -1] != '/') && (strchr(match,'?') == NULL)) {
17461746

1747-
canon = apr_psprintf(rule->ruleset->mp, "%s/", match);
1747+
canon = apr_psprintf(msr->mp, "%s/", match);
17481748
if (canon != NULL) {
17491749

17501750
canon_length = strlen(canon);
@@ -1757,7 +1757,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
17571757
log_escape_nq(msr->mp, canon));
17581758
}
17591759

1760-
str = apr_pstrdup(rule->ruleset->mp,match);
1760+
str = apr_pstrdup(msr->mp,match);
17611761

17621762
base = apr_strtok(str,"/",&savedptr);
17631763
if(base != NULL)
@@ -1770,7 +1770,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
17701770

17711771
/* Parsing full url */
17721772

1773-
domain = apr_pstrdup(rule->ruleset->mp, match);
1773+
domain = apr_pstrdup(msr->mp, match);
17741774

17751775
domain_len = strlen(domain);
17761776

@@ -1785,7 +1785,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
17851785

17861786
dot = strchr(domain,'.');
17871787
if(dot != NULL) {
1788-
canon = apr_pstrdup(rule->ruleset->mp, domain);
1788+
canon = apr_pstrdup(msr->mp, domain);
17891789

17901790
ret = verify_gsb(gsb, msr, canon, strlen(canon));
17911791

@@ -1796,7 +1796,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
17961796
log_escape_nq(msr->mp, canon));
17971797
}
17981798

1799-
str = apr_pstrdup(rule->ruleset->mp,match);
1799+
str = apr_pstrdup(msr->mp,match);
18001800

18011801
base = apr_strtok(str,"/",&savedptr);
18021802
if(base != NULL)
@@ -1818,7 +1818,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
18181818
log_escape_nq(msr->mp, base));
18191819
}
18201820

1821-
str = apr_pstrdup(rule->ruleset->mp,match);
1821+
str = apr_pstrdup(msr->mp,match);
18221822

18231823
base = apr_strtok(str,"/",&savedptr);
18241824
if(base != NULL)
@@ -1829,13 +1829,13 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
18291829

18301830
}
18311831

1832-
url = apr_palloc(rule->ruleset->mp, strlen(canon));
1832+
url = apr_palloc(msr->mp, strlen(canon));
18331833
count_slash = 0;
18341834

18351835
while(*canon != '\0') {
18361836
switch (*canon) {
18371837
case '/':
1838-
ptr = apr_psprintf(rule->ruleset->mp,"%s/",url);
1838+
ptr = apr_psprintf(msr->mp,"%s/",url);
18391839
ret = verify_gsb(gsb, msr, ptr, strlen(ptr));
18401840
if(ret > 0) {
18411841
set_match_to_tx(msr, capture, ptr, 0);
@@ -1844,7 +1844,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
18441844
log_escape_nq(msr->mp, ptr));
18451845
}
18461846

1847-
str = apr_pstrdup(rule->ruleset->mp,match);
1847+
str = apr_pstrdup(msr->mp,match);
18481848

18491849
base = apr_strtok(str,"/",&savedptr);
18501850
if(base != NULL)
@@ -1871,7 +1871,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
18711871
}
18721872

18731873

1874-
str = apr_pstrdup(rule->ruleset->mp, match);
1874+
str = apr_pstrdup(msr->mp, match);
18751875

18761876
while (*str != '\0') {
18771877

@@ -1896,7 +1896,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
18961896

18971897
dot = strchr(domain,'.');
18981898
if(dot != NULL) {
1899-
canon = apr_pstrdup(rule->ruleset->mp, domain);
1899+
canon = apr_pstrdup(msr->mp, domain);
19001900

19011901
ret = verify_gsb(gsb, msr, canon, strlen(canon));
19021902

@@ -1906,7 +1906,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
19061906
*error_msg = apr_psprintf(msr->mp, "Gsb lookup for \"%s\" succeeded.",
19071907
log_escape_nq(msr->mp, canon));
19081908
}
1909-
str = apr_pstrdup(rule->ruleset->mp,match);
1909+
str = apr_pstrdup(msr->mp,match);
19101910

19111911
base = apr_strtok(str,"/",&savedptr);
19121912
if(base != NULL)
@@ -1926,7 +1926,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
19261926
*error_msg = apr_psprintf(msr->mp, "Gsb lookup for \"%s\" succeeded.",
19271927
log_escape_nq(msr->mp, base));
19281928
}
1929-
str = apr_pstrdup(rule->ruleset->mp,match);
1929+
str = apr_pstrdup(msr->mp,match);
19301930

19311931
base = apr_strtok(str,"/",&savedptr);
19321932
if(base != NULL)
@@ -1936,21 +1936,21 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
19361936

19371937
}
19381938

1939-
url = apr_palloc(rule->ruleset->mp, strlen(canon));
1939+
url = apr_palloc(msr->mp, strlen(canon));
19401940
count_slash = 0;
19411941

19421942
while(*canon != '\0') {
19431943
switch (*canon) {
19441944
case '/':
1945-
ptr = apr_psprintf(rule->ruleset->mp,"%s/",url);
1945+
ptr = apr_psprintf(msr->mp,"%s/",url);
19461946
ret = verify_gsb(gsb, msr, ptr, strlen(ptr));
19471947
if(ret > 0) {
19481948
set_match_to_tx(msr, capture, ptr, 0);
19491949
if (! *error_msg) {
19501950
*error_msg = apr_psprintf(msr->mp, "Gsb lookup for \"%s\" succeeded.",
19511951
log_escape_nq(msr->mp, ptr));
19521952
}
1953-
str = apr_pstrdup(rule->ruleset->mp,match);
1953+
str = apr_pstrdup(msr->mp,match);
19541954

19551955
base = apr_strtok(str,"/",&savedptr);
19561956
if(base != NULL)
@@ -2781,7 +2781,7 @@ static int msre_op_verifyCC_execute(modsec_rec *msr, msre_rule *rule, msre_var *
27812781
if (msr->txcfg->debuglog_level >= 4) {
27822782
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
27832783
if ((rc != 0) || (jit != 1)) {
2784-
*error_msg = apr_psprintf(rule->ruleset->mp,
2784+
*error_msg = apr_psprintf(msr->mp,
27852785
"Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - "
27862786
"Execution error - "
27872787
"Does not support JIT (%d)",
@@ -3092,7 +3092,7 @@ static int msre_op_verifyCPF_execute(modsec_rec *msr, msre_rule *rule, msre_var
30923092
if (msr->txcfg->debuglog_level >= 4) {
30933093
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
30943094
if ((rc != 0) || (jit != 1)) {
3095-
*error_msg = apr_psprintf(rule->ruleset->mp,
3095+
*error_msg = apr_psprintf(msr->mp,
30963096
"Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - "
30973097
"Execution error - "
30983098
"Does not support JIT (%d)",
@@ -3386,7 +3386,7 @@ static int msre_op_verifySSN_execute(modsec_rec *msr, msre_rule *rule, msre_var
33863386
if (msr->txcfg->debuglog_level >= 4) {
33873387
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
33883388
if ((rc != 0) || (jit != 1)) {
3389-
*error_msg = apr_psprintf(rule->ruleset->mp,
3389+
*error_msg = apr_psprintf(msr->mp,
33903390
"Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - "
33913391
"Execution error - "
33923392
"Does not support JIT (%d)",
@@ -3967,7 +3967,7 @@ static int msre_op_fuzzy_hash_execute(modsec_rec *msr, msre_rule *rule,
39673967
#ifdef WITH_SSDEEP
39683968
if (fuzzy_hash_buf(var->value, var->value_len, result))
39693969
{
3970-
*error_msg = apr_psprintf(rule->ruleset->mp, "Problems generating " \
3970+
*error_msg = apr_psprintf(msr->mp, "Problems generating " \
39713971
"fuzzy hash.");
39723972

39733973
return -1;
@@ -3987,7 +3987,7 @@ static int msre_op_fuzzy_hash_execute(modsec_rec *msr, msre_rule *rule,
39873987
chunk = chunk->next;
39883988
}
39893989
#else
3990-
*error_msg = apr_psprintf(rule->ruleset->mp, "ModSecurity was not " \
3990+
*error_msg = apr_psprintf(msr->mp, "ModSecurity was not " \
39913991
"compiled with ssdeep support.");
39923992

39933993
return -1;

0 commit comments

Comments
 (0)