Skip to content

fix: add msc_fullinfo() to check JIT compilation #3375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions apache2/re_operators.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@

#include "libinjection/libinjection.h"

#ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT
#ifdef WITH_PCRE2
/**
* @brief Set the JIT compile return code and JIT compile status.
* \param regex regex structure
* \param rc return code of the JIT compile
* \param jit JIT compile status
* \return void
*/
static void msc_op_set_jitrc(msc_regex_t *regex, int *rc, int *jit) {
*rc = regex->jit_compile_rc;
if (*rc == 0) {
msc_fullinfo(regex, PCRE2_INFO_JITSIZE, jit);
*jit = (*jit > 0) ? 1 : 0;
}
return;
}
#endif
#endif
#endif

/**
*
Expand Down Expand Up @@ -724,7 +745,7 @@ static int msre_op_validateHash_param_init(msre_rule *rule, char **error_msg) {
#ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
msc_op_set_jitrc(regex, &rc, &jit);
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
Expand Down Expand Up @@ -830,7 +851,7 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v
#ifdef WITH_PCRE_JIT
if (msr->txcfg->debuglog_level >= 4) {
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
msc_op_set_jitrc(regex, &rc, &jit);
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
Expand Down Expand Up @@ -1001,7 +1022,7 @@ static int msre_op_rx_param_init(msre_rule *rule, char **error_msg) {
#ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
msc_op_set_jitrc(regex, &rc, &jit);
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
Expand Down Expand Up @@ -1099,7 +1120,7 @@ static int msre_op_rx_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, c
#ifdef WITH_PCRE_JIT
if (msr->txcfg->debuglog_level >= 4) {
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
msc_op_set_jitrc(regex, &rc, &jit);
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
Expand Down Expand Up @@ -2990,7 +3011,7 @@ static int msre_op_verifyCC_execute(modsec_rec *msr, msre_rule *rule, msre_var *
#ifdef WITH_PCRE_JIT
if (msr->txcfg->debuglog_level >= 4) {
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
msc_op_set_jitrc(regex, &rc, &jit);
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
Expand Down Expand Up @@ -3329,7 +3350,7 @@ static int msre_op_verifyCPF_execute(modsec_rec *msr, msre_rule *rule, msre_var
#ifdef WITH_PCRE_JIT
if (msr->txcfg->debuglog_level >= 4) {
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
msc_op_set_jitrc(regex, &rc, &jit);
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
Expand Down Expand Up @@ -3654,7 +3675,7 @@ static int msre_op_verifySSN_execute(modsec_rec *msr, msre_rule *rule, msre_var
#ifdef WITH_PCRE_JIT
if (msr->txcfg->debuglog_level >= 4) {
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
msc_op_set_jitrc(regex, &rc, &jit);
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
Expand Down