Skip to content

Commit e0e732a

Browse files
authored
Merge pull request #3375 from airween/v2/failjiterr
fix: add msc_fullinfo() to check JIT compilation
2 parents 06cb10f + 33d0f50 commit e0e732a

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

apache2/re_operators.c

+28-7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@
3737

3838
#include "libinjection/libinjection.h"
3939

40+
#ifdef WITH_PCRE_STUDY
41+
#ifdef WITH_PCRE_JIT
42+
#ifdef WITH_PCRE2
43+
/**
44+
* @brief Set the JIT compile return code and JIT compile status.
45+
* \param regex regex structure
46+
* \param rc return code of the JIT compile
47+
* \param jit JIT compile status
48+
* \return void
49+
*/
50+
static void msc_op_set_jitrc(msc_regex_t *regex, int *rc, int *jit) {
51+
*rc = regex->jit_compile_rc;
52+
if (*rc == 0) {
53+
msc_fullinfo(regex, PCRE2_INFO_JITSIZE, jit);
54+
*jit = (*jit > 0) ? 1 : 0;
55+
}
56+
return;
57+
}
58+
#endif
59+
#endif
60+
#endif
4061

4162
/**
4263
*
@@ -724,7 +745,7 @@ static int msre_op_validateHash_param_init(msre_rule *rule, char **error_msg) {
724745
#ifdef WITH_PCRE_STUDY
725746
#ifdef WITH_PCRE_JIT
726747
#ifdef WITH_PCRE2
727-
rc = regex->jit_compile_rc;
748+
msc_op_set_jitrc(regex, &rc, &jit);
728749
#else
729750
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
730751
#endif
@@ -830,7 +851,7 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v
830851
#ifdef WITH_PCRE_JIT
831852
if (msr->txcfg->debuglog_level >= 4) {
832853
#ifdef WITH_PCRE2
833-
rc = regex->jit_compile_rc;
854+
msc_op_set_jitrc(regex, &rc, &jit);
834855
#else
835856
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
836857
#endif
@@ -1001,7 +1022,7 @@ static int msre_op_rx_param_init(msre_rule *rule, char **error_msg) {
10011022
#ifdef WITH_PCRE_STUDY
10021023
#ifdef WITH_PCRE_JIT
10031024
#ifdef WITH_PCRE2
1004-
rc = regex->jit_compile_rc;
1025+
msc_op_set_jitrc(regex, &rc, &jit);
10051026
#else
10061027
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
10071028
#endif
@@ -1099,7 +1120,7 @@ static int msre_op_rx_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, c
10991120
#ifdef WITH_PCRE_JIT
11001121
if (msr->txcfg->debuglog_level >= 4) {
11011122
#ifdef WITH_PCRE2
1102-
rc = regex->jit_compile_rc;
1123+
msc_op_set_jitrc(regex, &rc, &jit);
11031124
#else
11041125
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
11051126
#endif
@@ -2990,7 +3011,7 @@ static int msre_op_verifyCC_execute(modsec_rec *msr, msre_rule *rule, msre_var *
29903011
#ifdef WITH_PCRE_JIT
29913012
if (msr->txcfg->debuglog_level >= 4) {
29923013
#ifdef WITH_PCRE2
2993-
rc = regex->jit_compile_rc;
3014+
msc_op_set_jitrc(regex, &rc, &jit);
29943015
#else
29953016
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
29963017
#endif
@@ -3329,7 +3350,7 @@ static int msre_op_verifyCPF_execute(modsec_rec *msr, msre_rule *rule, msre_var
33293350
#ifdef WITH_PCRE_JIT
33303351
if (msr->txcfg->debuglog_level >= 4) {
33313352
#ifdef WITH_PCRE2
3332-
rc = regex->jit_compile_rc;
3353+
msc_op_set_jitrc(regex, &rc, &jit);
33333354
#else
33343355
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
33353356
#endif
@@ -3654,7 +3675,7 @@ static int msre_op_verifySSN_execute(modsec_rec *msr, msre_rule *rule, msre_var
36543675
#ifdef WITH_PCRE_JIT
36553676
if (msr->txcfg->debuglog_level >= 4) {
36563677
#ifdef WITH_PCRE2
3657-
rc = regex->jit_compile_rc;
3678+
msc_op_set_jitrc(regex, &rc, &jit);
36583679
#else
36593680
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
36603681
#endif

0 commit comments

Comments
 (0)