|
37 | 37 |
|
38 | 38 | #include "libinjection/libinjection.h"
|
39 | 39 |
|
| 40 | +/** |
| 41 | + * @brief Set the JIT compile return code and JIT compile status. |
| 42 | + * \param regex regex structure |
| 43 | + * \param rc return code of the JIT compile |
| 44 | + * \param jit JIT compile status |
| 45 | + * \return void |
| 46 | + */ |
| 47 | +static void msc_op_set_jitrc(msc_regex_t *regex, int *rc, int *jit) { |
| 48 | + *rc = regex->jit_compile_rc; |
| 49 | + if (*rc == 0) { |
| 50 | + msc_fullinfo(regex, PCRE2_INFO_JITSIZE, jit); |
| 51 | + *jit = (*jit > 0) ? 1 : 0; |
| 52 | + } |
| 53 | + return; |
| 54 | +} |
40 | 55 |
|
41 | 56 | /**
|
42 | 57 | *
|
@@ -724,11 +739,7 @@ static int msre_op_validateHash_param_init(msre_rule *rule, char **error_msg) {
|
724 | 739 | #ifdef WITH_PCRE_STUDY
|
725 | 740 | #ifdef WITH_PCRE_JIT
|
726 | 741 | #ifdef WITH_PCRE2
|
727 |
| - rc = regex->jit_compile_rc; |
728 |
| - if (rc == 0) { |
729 |
| - msc_fullinfo(regex, PCRE2_INFO_JITSIZE, &jit); |
730 |
| - jit = (jit > 0) ? 1 : 0; |
731 |
| - } |
| 742 | + msc_op_set_jitrc(regex, &rc, &jit); |
732 | 743 | #else
|
733 | 744 | rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
|
734 | 745 | #endif
|
@@ -834,11 +845,7 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v
|
834 | 845 | #ifdef WITH_PCRE_JIT
|
835 | 846 | if (msr->txcfg->debuglog_level >= 4) {
|
836 | 847 | #ifdef WITH_PCRE2
|
837 |
| - rc = regex->jit_compile_rc; |
838 |
| - if (rc == 0) { |
839 |
| - msc_fullinfo(regex, PCRE2_INFO_JITSIZE, &jit); |
840 |
| - jit = (jit > 0) ? 1 : 0; |
841 |
| - } |
| 848 | + msc_op_set_jitrc(regex, &rc, &jit); |
842 | 849 | #else
|
843 | 850 | rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
|
844 | 851 | #endif
|
@@ -1009,11 +1016,7 @@ static int msre_op_rx_param_init(msre_rule *rule, char **error_msg) {
|
1009 | 1016 | #ifdef WITH_PCRE_STUDY
|
1010 | 1017 | #ifdef WITH_PCRE_JIT
|
1011 | 1018 | #ifdef WITH_PCRE2
|
1012 |
| - rc = regex->jit_compile_rc; |
1013 |
| - if (rc == 0) { |
1014 |
| - msc_fullinfo(regex, PCRE2_INFO_JITSIZE, &jit); |
1015 |
| - jit = (jit > 0) ? 1 : 0; |
1016 |
| - } |
| 1019 | + msc_op_set_jitrc(regex, &rc, &jit); |
1017 | 1020 | #else
|
1018 | 1021 | rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
|
1019 | 1022 | #endif
|
@@ -1111,11 +1114,7 @@ static int msre_op_rx_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, c
|
1111 | 1114 | #ifdef WITH_PCRE_JIT
|
1112 | 1115 | if (msr->txcfg->debuglog_level >= 4) {
|
1113 | 1116 | #ifdef WITH_PCRE2
|
1114 |
| - rc = regex->jit_compile_rc; |
1115 |
| - if (rc == 0) { |
1116 |
| - msc_fullinfo(regex, PCRE2_INFO_JITSIZE, &jit); |
1117 |
| - jit = (jit > 0) ? 1 : 0; |
1118 |
| - } |
| 1117 | + msc_op_set_jitrc(regex, &rc, &jit); |
1119 | 1118 | #else
|
1120 | 1119 | rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
|
1121 | 1120 | #endif
|
@@ -3006,11 +3005,7 @@ static int msre_op_verifyCC_execute(modsec_rec *msr, msre_rule *rule, msre_var *
|
3006 | 3005 | #ifdef WITH_PCRE_JIT
|
3007 | 3006 | if (msr->txcfg->debuglog_level >= 4) {
|
3008 | 3007 | #ifdef WITH_PCRE2
|
3009 |
| - rc = regex->jit_compile_rc; |
3010 |
| - if (rc == 0) { |
3011 |
| - msc_fullinfo(regex, PCRE2_INFO_JITSIZE, &jit); |
3012 |
| - jit = (jit > 0) ? 1 : 0; |
3013 |
| - } |
| 3008 | + msc_op_set_jitrc(regex, &rc, &jit); |
3014 | 3009 | #else
|
3015 | 3010 | rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
|
3016 | 3011 | #endif
|
@@ -3349,11 +3344,7 @@ static int msre_op_verifyCPF_execute(modsec_rec *msr, msre_rule *rule, msre_var
|
3349 | 3344 | #ifdef WITH_PCRE_JIT
|
3350 | 3345 | if (msr->txcfg->debuglog_level >= 4) {
|
3351 | 3346 | #ifdef WITH_PCRE2
|
3352 |
| - rc = regex->jit_compile_rc; |
3353 |
| - if (rc == 0) { |
3354 |
| - msc_fullinfo(regex, PCRE2_INFO_JITSIZE, &jit); |
3355 |
| - jit = (jit > 0) ? 1 : 0; |
3356 |
| - } |
| 3347 | + msc_op_set_jitrc(regex, &rc, &jit); |
3357 | 3348 | #else
|
3358 | 3349 | rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
|
3359 | 3350 | #endif
|
@@ -3678,11 +3669,7 @@ static int msre_op_verifySSN_execute(modsec_rec *msr, msre_rule *rule, msre_var
|
3678 | 3669 | #ifdef WITH_PCRE_JIT
|
3679 | 3670 | if (msr->txcfg->debuglog_level >= 4) {
|
3680 | 3671 | #ifdef WITH_PCRE2
|
3681 |
| - rc = regex->jit_compile_rc; |
3682 |
| - if (rc == 0) { |
3683 |
| - msc_fullinfo(regex, PCRE2_INFO_JITSIZE, &jit); |
3684 |
| - jit = (jit > 0) ? 1 : 0; |
3685 |
| - } |
| 3672 | + msc_op_set_jitrc(regex, &rc, &jit); |
3686 | 3673 | #else
|
3687 | 3674 | rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
|
3688 | 3675 | #endif
|
|
0 commit comments