"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "apache2/re_operators.c" between
modsecurity-2.9.6.tar.gz and modsecurity-2.9.7.tar.gz

About: ModSecurity is an intrusion detection and prevention module (web application firewall) for the Apache (and Nginx) Web servers.

re_operators.c  (modsecurity-2.9.6):re_operators.c  (modsecurity-2.9.7)
/* /*
* ModSecurity for Apache 2.x, http://www.modsecurity.org/ * ModSecurity for Apache 2.x, http://www.modsecurity.org/
* Copyright (c) 2004-2013 Trustwave Holdings, Inc. (http://www.trustwave.com/) * Copyright (c) 2004-2022 Trustwave Holdings, Inc. (http://www.trustwave.com/)
* *
* You may not use this file except in compliance with * You may not use this file except in compliance with
* the License.  You may obtain a copy of the License at * the License.  You may obtain a copy of the License at
* *
*     http://www.apache.org/licenses/LICENSE-2.0 *     http://www.apache.org/licenses/LICENSE-2.0
* *
* If any of the files related to licensing are missing or if you have any * If any of the files related to licensing are missing or if you have any
* other questions related to licensing please contact Trustwave Holdings, Inc. * other questions related to licensing please contact Trustwave Holdings, Inc.
* directly using the email address security@modsecurity.org. * directly using the email address security@modsecurity.org.
*/ */
skipping to change at line 696 skipping to change at line 696
#ifdef WITH_PCRE_JIT #ifdef WITH_PCRE_JIT
int rc, jit; int rc, jit;
#endif #endif
#endif #endif
if (error_msg == NULL) return -1; if (error_msg == NULL) return -1;
*error_msg = NULL; *error_msg = NULL;
/* Compile pattern */ /* Compile pattern */
if(strstr(pattern,"%{") == NULL) { if(strstr(pattern,"%{") == NULL) {
regex = msc_pregcomp_ex(rule->ruleset->mp, pattern, PCRE_DOTALL | PCRE_D #ifdef WITH_PCRE2
OLLAR_ENDONLY, &errptr, &erroffset, msc_pcre_match_limit, msc_pcre_match_limit_r int options = PCRE2_DOTALL | PCRE2_DOLLAR_ENDONLY;
ecursion); #else
int options = PCRE_DOTALL | PCRE_DOLLAR_ENDONLY;
#endif
regex = msc_pregcomp_ex(rule->ruleset->mp, pattern, options, &errptr, &e
rroffset, msc_pcre_match_limit, msc_pcre_match_limit_recursion);
if (regex == NULL) { if (regex == NULL) {
*error_msg = apr_psprintf(rule->ruleset->mp, "Error compiling patter n (offset %d): %s", *error_msg = apr_psprintf(rule->ruleset->mp, "Error compiling patter n (offset %d): %s",
erroffset, errptr); erroffset, errptr);
return 0; return 0;
} }
#ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT #ifdef WITH_PCRE_JIT
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
if ((rc != 0) || (jit != 1)) { if ((rc != 0) || (jit != 1)) {
*error_msg = apr_psprintf(rule->ruleset->mp, *error_msg = apr_psprintf(rule->ruleset->mp,
"Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - " "Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - "
"Execution error - " "Execution error - "
"Does not support JIT (%d)", "Does not support JIT (%d)",
rule,((rule->actionset != NULL)&&((rule->actionset->id != NU LL)&& rule,((rule->actionset != NULL)&&((rule->actionset->id != NU LL)&&
(rule->actionset->id != NOT_SET_P))) ? rule->actions et->id : "-", (rule->actionset->id != NOT_SET_P))) ? rule->actions et->id : "-",
rule->filename != NULL ? rule->filename : "-", rule->filename != NULL ? rule->filename : "-",
rule->line_num,rc); rule->line_num,rc);
} }
skipping to change at line 746 skipping to change at line 755
* *
* \retval 1 On success * \retval 1 On success
* \retval 0 On fail * \retval 0 On fail
*/ */
static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v ar *var, char **error_msg) { static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v ar *var, char **error_msg) {
msc_regex_t *regex = (msc_regex_t *)rule->op_param_data; msc_regex_t *regex = (msc_regex_t *)rule->op_param_data;
msc_string *re_pattern = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_strin g)); msc_string *re_pattern = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_strin g));
const char *target; const char *target;
const char *errptr = NULL; const char *errptr = NULL;
int erroffset; int erroffset;
int options = 0;
unsigned int target_length; unsigned int target_length;
char *my_error_msg = NULL; char *my_error_msg = NULL;
int ovector[33]; int ovector[33];
int rc; int rc;
const char *pattern = NULL; const char *pattern = NULL;
#ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT #ifdef WITH_PCRE_JIT
int jit; int jit;
#endif #endif
#endif #endif
skipping to change at line 784 skipping to change at line 794
re_pattern->value = apr_pstrndup(msr->mp, rule->re_str, strlen(rule- >re_str)); re_pattern->value = apr_pstrndup(msr->mp, rule->re_str, strlen(rule- >re_str));
re_pattern->value_len = strlen(re_pattern->value); re_pattern->value_len = strlen(re_pattern->value);
expand_macros(msr, re_pattern, rule, msr->mp); expand_macros(msr, re_pattern, rule, msr->mp);
pattern = log_escape_re(msr->mp, re_pattern->value); pattern = log_escape_re(msr->mp, re_pattern->value);
if (msr->txcfg->debuglog_level >= 6) { if (msr->txcfg->debuglog_level >= 6) {
msr_log(msr, 6, "Escaping pattern [%s]",pattern); msr_log(msr, 6, "Escaping pattern [%s]",pattern);
} }
regex = msc_pregcomp_ex(msr->mp, pattern, PCRE_DOTALL | PCRE_DOLLAR_ #ifdef WITH_PCRE2
ENDONLY, &errptr, options = PCRE2_DOTALL | PCRE2_DOLLAR_ENDONLY;
#else
options = PCRE_DOTALL | PCRE_DOLLAR_ENDONLY;
#endif
regex = msc_pregcomp_ex(msr->mp, pattern, options, &errptr,
&erroffset, msc_pcre_match_limit, msc_pcre_match_limit_recur sion); &erroffset, msc_pcre_match_limit, msc_pcre_match_limit_recur sion);
if (regex == NULL) { if (regex == NULL) {
*error_msg = apr_psprintf(msr->mp, "Error compiling pattern (off set %d): %s", *error_msg = apr_psprintf(msr->mp, "Error compiling pattern (off set %d): %s",
erroffset, errptr); erroffset, errptr);
return 0; return 0;
} }
#ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT #ifdef WITH_PCRE_JIT
if (msr->txcfg->debuglog_level >= 4) { if (msr->txcfg->debuglog_level >= 4) {
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
if ((rc != 0) || (jit != 1)) { if ((rc != 0) || (jit != 1)) {
*error_msg = apr_psprintf(msr->mp, *error_msg = apr_psprintf(msr->mp,
"Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - " "Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - "
"Execution error - " "Execution error - "
"Does not support JIT (%d)", "Does not support JIT (%d)",
rule,((rule->actionset != NULL)&&((rule->actionset-> id != NULL)&& rule,((rule->actionset != NULL)&&((rule->actionset-> id != NULL)&&
(rule->actionset->id != NOT_SET_P))) ? rule- >actionset->id : "-", (rule->actionset->id != NOT_SET_P))) ? rule- >actionset->id : "-",
rule->filename != NULL ? rule->filename : "-", rule->filename != NULL ? rule->filename : "-",
rule->line_num,rc); rule->line_num,rc);
msr_log(msr, 4, "%s.", *error_msg); msr_log(msr, 4, "%s.", *error_msg);
skipping to change at line 829 skipping to change at line 848
target_length = 0; target_length = 0;
} else { } else {
target = var->value; target = var->value;
target_length = var->value_len; target_length = var->value_len;
} }
/* We always use capture so that ovector can be used as working space /* We always use capture so that ovector can be used as working space
* and no memory has to be allocated for any backreferences. * and no memory has to be allocated for any backreferences.
*/ */
rc = msc_regexec_capture(regex, target, target_length, ovector, 30, &my_erro r_msg); rc = msc_regexec_capture(regex, target, target_length, ovector, 30, &my_erro r_msg);
#ifdef WITH_PCRE2
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
#else
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) { if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
#endif
msc_string *s = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string)); msc_string *s = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string));
if (s == NULL) return -1; if (s == NULL) return -1;
s->name = apr_pstrdup(msr->mp, "MSC_PCRE_LIMITS_EXCEEDED"); s->name = apr_pstrdup(msr->mp, "MSC_PCRE_LIMITS_EXCEEDED");
if (s->name == NULL) return -1; if (s->name == NULL) return -1;
s->name_len = strlen(s->name); s->name_len = strlen(s->name);
s->value = apr_pstrdup(msr->mp, "1"); s->value = apr_pstrdup(msr->mp, "1");
if (s->value == NULL) return -1; if (s->value == NULL) return -1;
s->value_len = 1; s->value_len = 1;
apr_table_setn(msr->tx_vars, s->name, (void *)s); apr_table_setn(msr->tx_vars, s->name, (void *)s);
skipping to change at line 859 skipping to change at line 882
msr_log(msr, 3, "%s.", *error_msg); msr_log(msr, 3, "%s.", *error_msg);
return 0; /* No match. */ return 0; /* No match. */
} }
else if (rc < -1) { else if (rc < -1) {
*error_msg = apr_psprintf(msr->mp, "Regex execution failed (%d): %s", *error_msg = apr_psprintf(msr->mp, "Regex execution failed (%d): %s",
rc, my_error_msg); rc, my_error_msg);
return -1; return -1;
} }
#ifdef WITH_PCRE2
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
#else
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */ if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
#endif
/* We no longer escape the pattern here as it is done when logging */ /* We no longer escape the pattern here as it is done when logging */
char *pattern = apr_pstrdup(msr->mp, log_escape(msr->mp, regex->pattern ? regex->pattern : "<Unknown Match>")); char *pattern = apr_pstrdup(msr->mp, log_escape(msr->mp, regex->pattern ? regex->pattern : "<Unknown Match>"));
char *hmac = NULL, *valid = NULL; char *hmac = NULL, *valid = NULL;
char *hash_link = NULL, *nlink = NULL; char *hash_link = NULL, *nlink = NULL;
if (strlen(pattern) > 252) { if (strlen(pattern) > 252) {
*error_msg = apr_psprintf(msr->mp, "Request URI matched \"%.252s ... \" at %s.", *error_msg = apr_psprintf(msr->mp, "Request URI matched \"%.252s ... \" at %s.",
pattern, var->name); pattern, var->name);
} else { } else {
*error_msg = apr_psprintf(msr->mp, "Request URI matched \"%s\" at %s .", *error_msg = apr_psprintf(msr->mp, "Request URI matched \"%s\" at %s .",
skipping to change at line 938 skipping to change at line 965
#ifdef WITH_PCRE_JIT #ifdef WITH_PCRE_JIT
int rc, jit; int rc, jit;
#endif #endif
#endif #endif
if (error_msg == NULL) return -1; if (error_msg == NULL) return -1;
*error_msg = NULL; *error_msg = NULL;
/* Compile pattern */ /* Compile pattern */
if(strstr(pattern,"%{") == NULL) { if(strstr(pattern,"%{") == NULL) {
regex = msc_pregcomp_ex(rule->ruleset->mp, pattern, PCRE_DOTALL | PCRE_D #ifdef WITH_PCRE2
OLLAR_ENDONLY, &errptr, &erroffset, msc_pcre_match_limit, msc_pcre_match_limit_r int options = PCRE2_DOTALL | PCRE2_DOLLAR_ENDONLY;
ecursion); #else
int options = PCRE_DOTALL | PCRE_DOLLAR_ENDONLY;
#endif
regex = msc_pregcomp_ex(rule->ruleset->mp, pattern, options, &errptr, &e
rroffset, msc_pcre_match_limit, msc_pcre_match_limit_recursion);
if (regex == NULL) { if (regex == NULL) {
*error_msg = apr_psprintf(rule->ruleset->mp, "Error compiling patter n (offset %d): %s", *error_msg = apr_psprintf(rule->ruleset->mp, "Error compiling patter n (offset %d): %s",
erroffset, errptr); erroffset, errptr);
return 0; return 0;
} }
#ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT #ifdef WITH_PCRE_JIT
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
if ((rc != 0) || (jit != 1)) { if ((rc != 0) || (jit != 1)) {
*error_msg = apr_psprintf(rule->ruleset->mp, *error_msg = apr_psprintf(rule->ruleset->mp,
"Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - " "Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - "
"Execution error - " "Execution error - "
"Does not support JIT (%d)", "Does not support JIT (%d)",
rule,((rule->actionset != NULL)&&((rule->actionset->id != NU LL)&& rule,((rule->actionset != NULL)&&((rule->actionset->id != NU LL)&&
(rule->actionset->id != NOT_SET_P))) ? rule->actions et->id : "-", (rule->actionset->id != NOT_SET_P))) ? rule->actions et->id : "-",
rule->filename != NULL ? rule->filename : "-", rule->filename != NULL ? rule->filename : "-",
rule->line_num,rc); rule->line_num,rc);
} }
skipping to change at line 977 skipping to change at line 1013
return 1; /* OK */ return 1; /* OK */
} }
static int msre_op_rx_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, c har **error_msg) { static int msre_op_rx_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, c har **error_msg) {
msc_regex_t *regex = (msc_regex_t *)rule->op_param_data; msc_regex_t *regex = (msc_regex_t *)rule->op_param_data;
msc_string *re_pattern = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_strin g)); msc_string *re_pattern = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_strin g));
const char *target; const char *target;
const char *errptr = NULL; const char *errptr = NULL;
int erroffset; int erroffset;
int options = 0;
unsigned int target_length; unsigned int target_length;
char *my_error_msg = NULL; char *my_error_msg = NULL;
int ovector[33]; int ovector[33];
int capture = 0; int capture = 0;
int matched_bytes = 0; int matched_bytes = 0;
int matched = 0; int matched = 0;
int rc; int rc;
char *qspos = NULL; char *qspos = NULL;
const char *parm = NULL, *pattern = NULL; const char *parm = NULL, *pattern = NULL;
msc_parm *mparm = NULL; msc_parm *mparm = NULL;
skipping to change at line 1017 skipping to change at line 1054
re_pattern->value = apr_pstrndup(msr->mp, rule->re_str, strlen(rule- >re_str)); re_pattern->value = apr_pstrndup(msr->mp, rule->re_str, strlen(rule- >re_str));
re_pattern->value_len = strlen(re_pattern->value); re_pattern->value_len = strlen(re_pattern->value);
expand_macros(msr, re_pattern, rule, msr->mp); expand_macros(msr, re_pattern, rule, msr->mp);
pattern = log_escape_re(msr->mp, re_pattern->value); pattern = log_escape_re(msr->mp, re_pattern->value);
if (msr->txcfg->debuglog_level >= 6) { if (msr->txcfg->debuglog_level >= 6) {
msr_log(msr, 6, "Escaping pattern [%s]",pattern); msr_log(msr, 6, "Escaping pattern [%s]",pattern);
} }
regex = msc_pregcomp_ex(msr->mp, pattern, PCRE_DOTALL | PCRE_DOLLAR_ #ifdef WITH_PCRE2
ENDONLY, &errptr, &erroffset, msc_pcre_match_limit, msc_pcre_match_limit_recursi options = PCRE2_DOTALL | PCRE2_DOLLAR_ENDONLY;
on); #else
options = PCRE_DOTALL | PCRE_DOLLAR_ENDONLY;
#endif
regex = msc_pregcomp_ex(msr->mp, pattern, options, &errptr, &erroffs
et, msc_pcre_match_limit, msc_pcre_match_limit_recursion);
if (regex == NULL) { if (regex == NULL) {
*error_msg = apr_psprintf(msr->mp, "Error compiling pattern (off set %d): %s", *error_msg = apr_psprintf(msr->mp, "Error compiling pattern (off set %d): %s",
erroffset, errptr); erroffset, errptr);
return 0; return 0;
} }
#ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT #ifdef WITH_PCRE_JIT
if (msr->txcfg->debuglog_level >= 4) { if (msr->txcfg->debuglog_level >= 4) {
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
if ((rc != 0) || (jit != 1)) { if ((rc != 0) || (jit != 1)) {
*error_msg = apr_psprintf(msr->mp, *error_msg = apr_psprintf(msr->mp,
"Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - " "Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - "
"Execution error - " "Execution error - "
"Does not support JIT (%d)", "Does not support JIT (%d)",
rule,((rule->actionset != NULL)&&((rule->actionset-> id != NULL)&& rule,((rule->actionset != NULL)&&((rule->actionset-> id != NULL)&&
(rule->actionset->id != NOT_SET_P))) ? rule- >actionset->id : "-", (rule->actionset->id != NOT_SET_P))) ? rule- >actionset->id : "-",
rule->filename != NULL ? rule->filename : "-", rule->filename != NULL ? rule->filename : "-",
rule->line_num,rc); rule->line_num,rc);
msr_log(msr, 4, "%s.", *error_msg); msr_log(msr, 4, "%s.", *error_msg);
skipping to change at line 1071 skipping to change at line 1117
if(!matched_bytes) if(!matched_bytes)
matched_bytes = apr_table_get(rule->actionset->actions, "sanitiseMatched Bytes") ? 1 : 0; matched_bytes = apr_table_get(rule->actionset->actions, "sanitiseMatched Bytes") ? 1 : 0;
matched = apr_table_get(rule->actionset->actions, "sanitizeMatched") ? 1 : 0 ; matched = apr_table_get(rule->actionset->actions, "sanitizeMatched") ? 1 : 0 ;
if(!matched) if(!matched)
matched = apr_table_get(rule->actionset->actions, "sanitiseMatched") ? 1 : 0; matched = apr_table_get(rule->actionset->actions, "sanitiseMatched") ? 1 : 0;
/* Show when the regex captures but "capture" is not set */ /* Show when the regex captures but "capture" is not set */
if (msr->txcfg->debuglog_level >= 6) { if (msr->txcfg->debuglog_level >= 6) {
int capcount = 0; int capcount = 0;
#ifdef WITH_PCRE2
rc = msc_fullinfo(regex, PCRE2_INFO_CAPTURECOUNT, &capcount);
#else
rc = msc_fullinfo(regex, PCRE_INFO_CAPTURECOUNT, &capcount); rc = msc_fullinfo(regex, PCRE_INFO_CAPTURECOUNT, &capcount);
#endif
if (msr->txcfg->debuglog_level >= 6) { if (msr->txcfg->debuglog_level >= 6) {
if ((capture == 0) && (capcount > 0)) { if ((capture == 0) && (capcount > 0)) {
msr_log(msr, 6, "Ignoring regex captures since \"capture\" actio n is not enabled."); msr_log(msr, 6, "Ignoring regex captures since \"capture\" actio n is not enabled.");
} }
} }
} }
/* We always use capture so that ovector can be used as working space /* We always use capture so that ovector can be used as working space
* and no memory has to be allocated for any backreferences. * and no memory has to be allocated for any backreferences.
*/ */
rc = msc_regexec_capture(regex, target, target_length, ovector, 30, &my_erro r_msg); rc = msc_regexec_capture(regex, target, target_length, ovector, 30, &my_erro r_msg);
#ifdef WITH_PCRE2
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
#else
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) { if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
#endif
msc_string *s = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string)); msc_string *s = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string));
if (s == NULL) return -1; if (s == NULL) return -1;
s->name = apr_pstrdup(msr->mp, "MSC_PCRE_LIMITS_EXCEEDED"); s->name = apr_pstrdup(msr->mp, "MSC_PCRE_LIMITS_EXCEEDED");
if (s->name == NULL) return -1; if (s->name == NULL) return -1;
s->name_len = strlen(s->name); s->name_len = strlen(s->name);
s->value = apr_pstrdup(msr->mp, "1"); s->value = apr_pstrdup(msr->mp, "1");
if (s->value == NULL) return -1; if (s->value == NULL) return -1;
s->value_len = 1; s->value_len = 1;
apr_table_setn(msr->tx_vars, s->name, (void *)s); apr_table_setn(msr->tx_vars, s->name, (void *)s);
skipping to change at line 1174 skipping to change at line 1228
} }
} }
if (msr->txcfg->debuglog_level >= 9) { if (msr->txcfg->debuglog_level >= 9) {
msr_log(msr, 9, "Added regex subexpression to TX.%d: %s", i, msr_log(msr, 9, "Added regex subexpression to TX.%d: %s", i,
log_escape_nq_ex(msr->mp, s->value, s->value_len)); log_escape_nq_ex(msr->mp, s->value, s->value_len));
} }
} }
} }
#ifdef WITH_PCRE2
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
#else
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */ if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
#endif
/* We no longer escape the pattern here as it is done when logging */ /* We no longer escape the pattern here as it is done when logging */
char *pattern = apr_pstrdup(msr->mp, log_escape(msr->mp, regex->pattern ? regex->pattern : "<Unknown Match>")); char *pattern = apr_pstrdup(msr->mp, log_escape(msr->mp, regex->pattern ? regex->pattern : "<Unknown Match>"));
/* This message will be logged. */ /* This message will be logged. */
if (strlen(pattern) > 252) { if (strlen(pattern) > 252) {
*error_msg = apr_psprintf(msr->mp, "Pattern match \"%.252s ...\" at %s.", *error_msg = apr_psprintf(msr->mp, "Pattern match \"%.252s ...\" at %s.",
pattern, var->name); pattern, var->name);
} else { } else {
*error_msg = apr_psprintf(msr->mp, "Pattern match \"%s\" at %s.", *error_msg = apr_psprintf(msr->mp, "Pattern match \"%s\" at %s.",
pattern, var->name); pattern, var->name);
skipping to change at line 1617 skipping to change at line 1675
* *
* \param rule ModSecurity rule struct * \param rule ModSecurity rule struct
* \param error_msg Error message * \param error_msg Error message
* *
* \retval 1 On Success * \retval 1 On Success
* \retval 0 On Fail * \retval 0 On Fail
*/ */
static int msre_op_gsbLookup_param_init(msre_rule *rule, char **error_msg) { static int msre_op_gsbLookup_param_init(msre_rule *rule, char **error_msg) {
const char *errptr = NULL; const char *errptr = NULL;
int erroffset; int erroffset;
int options = 0;
msc_regex_t *regex; msc_regex_t *regex;
if (error_msg == NULL) return -1; if (error_msg == NULL) return -1;
*error_msg = NULL; *error_msg = NULL;
/* Compile rule->op_param */ /* Compile rule->op_param */
regex = msc_pregcomp_ex(rule->ruleset->mp, rule->op_param, PCRE_DOTALL | PCR #ifdef WITH_PCRE2
E_MULTILINE, &errptr, &erroffset, msc_pcre_match_limit, msc_pcre_match_limit_rec options = PCRE2_DOTALL | PCRE2_MULTILINE;
ursion); #else
options = PCRE_DOTALL | PCRE_MULTILINE;
#endif
regex = msc_pregcomp_ex(rule->ruleset->mp, rule->op_param, options, &errptr,
&erroffset, msc_pcre_match_limit, msc_pcre_match_limit_recursion);
if (regex == NULL) { if (regex == NULL) {
*error_msg = apr_psprintf(rule->ruleset->mp, "Error compiling pattern (o ffset %d): %s", *error_msg = apr_psprintf(rule->ruleset->mp, "Error compiling pattern (o ffset %d): %s",
erroffset, errptr); erroffset, errptr);
return 0; return 0;
} }
rule->op_param_data = regex; rule->op_param_data = regex;
return 1; /* OK */ return 1; /* OK */
skipping to change at line 1653 skipping to change at line 1717
* *
* \retval -1 On Failure * \retval -1 On Failure
* \retval 1 On Match * \retval 1 On Match
* \retval 0 On No Match * \retval 0 On No Match
*/ */
static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, char **error_msg) { static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, char **error_msg) {
msc_regex_t *regex = (msc_regex_t *)rule->op_param_data; msc_regex_t *regex = (msc_regex_t *)rule->op_param_data;
char *my_error_msg = NULL; char *my_error_msg = NULL;
int ovector[33]; int ovector[33];
unsigned int offset = 0; unsigned int offset = 0;
int options = 0;
gsb_db *gsb = msr->txcfg->gsb; gsb_db *gsb = msr->txcfg->gsb;
const char *match = NULL; const char *match = NULL;
unsigned int match_length; unsigned int match_length;
unsigned int canon_length; unsigned int canon_length;
int rv, i, ret, count_slash; int rv, i, ret, count_slash;
unsigned int j = 0; unsigned int j = 0;
unsigned int size = var->value_len; unsigned int size = var->value_len;
char *base = NULL, *domain = NULL, *savedptr = NULL; char *base = NULL, *domain = NULL, *savedptr = NULL;
char *str = NULL, *canon = NULL, *dot = NULL; char *str = NULL, *canon = NULL, *dot = NULL;
char *data = NULL, *ptr = NULL, *url = NULL; char *data = NULL, *ptr = NULL, *url = NULL;
skipping to change at line 1691 skipping to change at line 1756
if(data == NULL) { if(data == NULL) {
*error_msg = "Internal Error: cannot allocate memory for data."; *error_msg = "Internal Error: cannot allocate memory for data.";
return -1; return -1;
} }
capture = apr_table_get(rule->actionset->actions, "capture") ? 1 : 0; capture = apr_table_get(rule->actionset->actions, "capture") ? 1 : 0;
memcpy(data,var->value,var->value_len); memcpy(data,var->value,var->value_len);
while (offset < size && (rv = msc_regexec_ex(regex, data, size, offset, PCRE #ifdef WITH_PCRE2
_NOTEMPTY, ovector, 30, &my_error_msg)) >= 0) options = PCRE2_NOTEMPTY;
#else
options = PCRE_NOTEMPTY;
#endif
while (offset < size && (rv = msc_regexec_ex(regex, data, size, offset, opti
ons, ovector, 30, &my_error_msg)) >= 0)
{ {
for(i = 0; i < rv; ++i) for(i = 0; i < rv; ++i)
{ {
match = apr_psprintf(msr->mp, "%.*s", ovector[2*i+1] - ovector[2*i], data + ovector[2*i]); match = apr_psprintf(msr->mp, "%.*s", ovector[2*i+1] - ovector[2*i], data + ovector[2*i]);
if (match == NULL) { if (match == NULL) {
*error_msg = "Internal Error: cannot allocate memory for match." ; *error_msg = "Internal Error: cannot allocate memory for match." ;
return -1; return -1;
} }
skipping to change at line 2721 skipping to change at line 2791
/* Do a mod 10 on the sum */ /* Do a mod 10 on the sum */
sum[odd] %= 10; sum[odd] %= 10;
/* If the result is a zero the card is valid. */ /* If the result is a zero the card is valid. */
return sum[odd] ? 0 : 1; return sum[odd] ? 0 : 1;
} }
static int msre_op_verifyCC_init(msre_rule *rule, char **error_msg) { static int msre_op_verifyCC_init(msre_rule *rule, char **error_msg) {
const char *errptr = NULL; const char *errptr = NULL;
int erroffset; int erroffset;
int options = 0;
msc_regex_t *regex; msc_regex_t *regex;
if (error_msg == NULL) return -1; if (error_msg == NULL) return -1;
*error_msg = NULL; *error_msg = NULL;
#ifdef WITH_PCRE2
options = PCRE2_DOTALL | PCRE2_MULTILINE;
#else
options = PCRE_DOTALL | PCRE_MULTILINE;
#endif
/* Compile rule->op_param */ /* Compile rule->op_param */
regex = msc_pregcomp_ex(rule->ruleset->mp, rule->op_param, PCRE_DOTALL | PCR E_MULTILINE, &errptr, &erroffset, msc_pcre_match_limit, msc_pcre_match_limit_rec ursion); regex = msc_pregcomp_ex(rule->ruleset->mp, rule->op_param, options, &errptr, &erroffset, msc_pcre_match_limit, msc_pcre_match_limit_recursion);
if (regex == NULL) { if (regex == NULL) {
*error_msg = apr_psprintf(rule->ruleset->mp, "Error compiling pattern (o ffset %d): %s", *error_msg = apr_psprintf(rule->ruleset->mp, "Error compiling pattern (o ffset %d): %s",
erroffset, errptr); erroffset, errptr);
return 0; return 0;
} }
rule->op_param_data = regex; rule->op_param_data = regex;
return 1; /* OK */ return 1; /* OK */
} }
static int msre_op_verifyCC_execute(modsec_rec *msr, msre_rule *rule, msre_var * var, char **error_msg) { static int msre_op_verifyCC_execute(modsec_rec *msr, msre_rule *rule, msre_var * var, char **error_msg) {
msc_regex_t *regex = (msc_regex_t *)rule->op_param_data; msc_regex_t *regex = (msc_regex_t *)rule->op_param_data;
const char *target; const char *target;
unsigned int target_length; unsigned int target_length;
char *my_error_msg = NULL; char *my_error_msg = NULL;
int ovector[33]; int ovector[33];
int rc; int rc;
int is_cc = 0; int is_cc = 0;
int offset; int offset;
int options = 0;
int matched_bytes = 0; int matched_bytes = 0;
char *qspos = NULL; char *qspos = NULL;
const char *parm = NULL; const char *parm = NULL;
msc_parm *mparm = NULL; msc_parm *mparm = NULL;
#ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT #ifdef WITH_PCRE_JIT
int jit; int jit;
#endif #endif
#endif #endif
skipping to change at line 2771 skipping to change at line 2848
if (regex == NULL) { if (regex == NULL) {
*error_msg = "Internal Error: regex data is null."; *error_msg = "Internal Error: regex data is null.";
return -1; return -1;
} }
memset(ovector, 0, sizeof(ovector)); memset(ovector, 0, sizeof(ovector));
#ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT #ifdef WITH_PCRE_JIT
if (msr->txcfg->debuglog_level >= 4) { if (msr->txcfg->debuglog_level >= 4) {
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
if ((rc != 0) || (jit != 1)) { if ((rc != 0) || (jit != 1)) {
*error_msg = apr_psprintf(msr->mp, *error_msg = apr_psprintf(msr->mp,
"Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - " "Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - "
"Execution error - " "Execution error - "
"Does not support JIT (%d)", "Does not support JIT (%d)",
rule,((rule->actionset != NULL)&&((rule->actionset->id != NU LL)&& rule,((rule->actionset != NULL)&&((rule->actionset->id != NU LL)&&
(rule->actionset->id != NOT_SET_P))) ? rule->actions et->id : "-", (rule->actionset->id != NOT_SET_P))) ? rule->actions et->id : "-",
rule->filename != NULL ? rule->filename : "-", rule->filename != NULL ? rule->filename : "-",
rule->line_num,rc); rule->line_num,rc);
msr_log(msr, 4, "%s.", *error_msg); msr_log(msr, 4, "%s.", *error_msg);
skipping to change at line 2806 skipping to change at line 2887
target_length = var->value_len; target_length = var->value_len;
} }
for (offset = 0; ((unsigned int)offset < target_length) && (is_cc == 0); off set++) { for (offset = 0; ((unsigned int)offset < target_length) && (is_cc == 0); off set++) {
if (msr->txcfg->debuglog_level >= 9) { if (msr->txcfg->debuglog_level >= 9) {
if (offset > 0) { if (offset > 0) {
msr_log(msr, 9, "Continuing CC# search at target offset %d.", of fset); msr_log(msr, 9, "Continuing CC# search at target offset %d.", of fset);
} }
} }
rc = msc_regexec_ex(regex, target, target_length, offset, PCRE_NOTEMPTY, #ifdef WITH_PCRE2
ovector, 30, &my_error_msg); options = PCRE2_NOTEMPTY;
#else
options = PCRE_NOTEMPTY;
#endif
rc = msc_regexec_ex(regex, target, target_length, offset, options, ovect
or, 30, &my_error_msg);
/* If there was no match, then we are done. */ /* If there was no match, then we are done. */
#ifdef WITH_PCRE2
if (rc == PCRE2_ERROR_NOMATCH) {
#else
if (rc == PCRE_ERROR_NOMATCH) { if (rc == PCRE_ERROR_NOMATCH) {
#endif
break; break;
} }
if (rc < -1) { if (rc < -1) {
*error_msg = apr_psprintf(msr->mp, "CC# regex execution failed: %s", my_error_msg); *error_msg = apr_psprintf(msr->mp, "CC# regex execution failed: %s", my_error_msg);
return -1; return -1;
} }
/* Verify a match. */ /* Verify a match. */
if (rc > 0) { if (rc > 0) {
skipping to change at line 3016 skipping to change at line 3106
* *
* \param rule ModSecurity rule struct * \param rule ModSecurity rule struct
* \param error_msg Error message * \param error_msg Error message
* *
* \retval 0 On Failure * \retval 0 On Failure
* \retval 1 On Success * \retval 1 On Success
*/ */
static int msre_op_verifyCPF_init(msre_rule *rule, char **error_msg) { static int msre_op_verifyCPF_init(msre_rule *rule, char **error_msg) {
const char *errptr = NULL; const char *errptr = NULL;
int erroffset; int erroffset;
int options = 0;
msc_regex_t *regex; msc_regex_t *regex;
if (error_msg == NULL) return -1; if (error_msg == NULL) return -1;
*error_msg = NULL; *error_msg = NULL;
#ifdef WITH_PCRE2
options = PCRE2_DOTALL | PCRE2_MULTILINE;
#else
options = PCRE_DOTALL | PCRE_MULTILINE;
#endif
/* Compile rule->op_param */ /* Compile rule->op_param */
regex = msc_pregcomp_ex(rule->ruleset->mp, rule->op_param, PCRE_DOTALL | PCR E_MULTILINE, &errptr, &erroffset, msc_pcre_match_limit, msc_pcre_match_limit_rec ursion); regex = msc_pregcomp_ex(rule->ruleset->mp, rule->op_param, options, &errptr, &erroffset, msc_pcre_match_limit, msc_pcre_match_limit_recursion);
if (regex == NULL) { if (regex == NULL) {
*error_msg = apr_psprintf(rule->ruleset->mp, "Error compiling pattern (o ffset %d): %s", *error_msg = apr_psprintf(rule->ruleset->mp, "Error compiling pattern (o ffset %d): %s",
erroffset, errptr); erroffset, errptr);
return 0; return 0;
} }
rule->op_param_data = regex; rule->op_param_data = regex;
return 1; /* OK */ return 1; /* OK */
} }
skipping to change at line 3055 skipping to change at line 3151
*/ */
static int msre_op_verifyCPF_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, char **error_msg) { static int msre_op_verifyCPF_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, char **error_msg) {
msc_regex_t *regex = (msc_regex_t *)rule->op_param_data; msc_regex_t *regex = (msc_regex_t *)rule->op_param_data;
const char *target; const char *target;
unsigned int target_length; unsigned int target_length;
char *my_error_msg = NULL; char *my_error_msg = NULL;
int ovector[33]; int ovector[33];
int rc; int rc;
int is_cpf = 0; int is_cpf = 0;
int offset; int offset;
int options = 0;
int matched_bytes = 0; int matched_bytes = 0;
char *qspos = NULL; char *qspos = NULL;
const char *parm = NULL; const char *parm = NULL;
msc_parm *mparm = NULL; msc_parm *mparm = NULL;
#ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT #ifdef WITH_PCRE_JIT
int jit; int jit;
#endif #endif
#endif #endif
skipping to change at line 3078 skipping to change at line 3175
if (regex == NULL) { if (regex == NULL) {
*error_msg = "Internal Error: regex data is null."; *error_msg = "Internal Error: regex data is null.";
return -1; return -1;
} }
memset(ovector, 0, sizeof(ovector)); memset(ovector, 0, sizeof(ovector));
#ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT #ifdef WITH_PCRE_JIT
if (msr->txcfg->debuglog_level >= 4) { if (msr->txcfg->debuglog_level >= 4) {
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
if ((rc != 0) || (jit != 1)) { if ((rc != 0) || (jit != 1)) {
*error_msg = apr_psprintf(msr->mp, *error_msg = apr_psprintf(msr->mp,
"Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - " "Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - "
"Execution error - " "Execution error - "
"Does not support JIT (%d)", "Does not support JIT (%d)",
rule,((rule->actionset != NULL)&&((rule->actionset->id != NU LL)&& rule,((rule->actionset != NULL)&&((rule->actionset->id != NU LL)&&
(rule->actionset->id != NOT_SET_P))) ? rule->actions et->id : "-", (rule->actionset->id != NOT_SET_P))) ? rule->actions et->id : "-",
rule->filename != NULL ? rule->filename : "-", rule->filename != NULL ? rule->filename : "-",
rule->line_num,rc); rule->line_num,rc);
msr_log(msr, 4, "%s.", *error_msg); msr_log(msr, 4, "%s.", *error_msg);
skipping to change at line 3113 skipping to change at line 3214
target_length = var->value_len; target_length = var->value_len;
} }
for (offset = 0; ((unsigned int)offset < target_length) && (is_cpf == 0); of fset++) { for (offset = 0; ((unsigned int)offset < target_length) && (is_cpf == 0); of fset++) {
if (msr->txcfg->debuglog_level >= 9) { if (msr->txcfg->debuglog_level >= 9) {
if (offset > 0) { if (offset > 0) {
msr_log(msr, 9, "Continuing CPF# search at target offset %d.", o ffset); msr_log(msr, 9, "Continuing CPF# search at target offset %d.", o ffset);
} }
} }
rc = msc_regexec_ex(regex, target, target_length, offset, PCRE_NOTEMPTY, #ifdef WITH_PCRE2
ovector, 30, &my_error_msg); options = PCRE2_NOTEMPTY;
#else
options = PCRE_NOTEMPTY;
#endif
rc = msc_regexec_ex(regex, target, target_length, offset, options, ovect
or, 30, &my_error_msg);
/* If there was no match, then we are done. */ /* If there was no match, then we are done. */
#ifdef WITH_PCRE2
if (rc == PCRE2_ERROR_NOMATCH) {
#else
if (rc == PCRE_ERROR_NOMATCH) { if (rc == PCRE_ERROR_NOMATCH) {
#endif
break; break;
} }
if (rc < -1) { if (rc < -1) {
*error_msg = apr_psprintf(msr->mp, "CPF# regex execution failed: %s" , my_error_msg); *error_msg = apr_psprintf(msr->mp, "CPF# regex execution failed: %s" , my_error_msg);
return -1; return -1;
} }
/* Verify a match. */ /* Verify a match. */
if (rc > 0) { if (rc > 0) {
skipping to change at line 3309 skipping to change at line 3419
* *
* \param rule ModSecurity rule struct * \param rule ModSecurity rule struct
* \param error_msg Error message * \param error_msg Error message
* *
* \retval 0 On Failure * \retval 0 On Failure
* \retval 1 On Success * \retval 1 On Success
*/ */
static int msre_op_verifySSN_init(msre_rule *rule, char **error_msg) { static int msre_op_verifySSN_init(msre_rule *rule, char **error_msg) {
const char *errptr = NULL; const char *errptr = NULL;
int erroffset; int erroffset;
int options = 0;
msc_regex_t *regex; msc_regex_t *regex;
if (error_msg == NULL) return -1; if (error_msg == NULL) return -1;
*error_msg = NULL; *error_msg = NULL;
#ifdef WITH_PCRE2
options = PCRE2_DOTALL | PCRE2_MULTILINE;
#else
options = PCRE_DOTALL | PCRE_MULTILINE;
#endif
/* Compile rule->op_param */ /* Compile rule->op_param */
regex = msc_pregcomp_ex(rule->ruleset->mp, rule->op_param, PCRE_DOTALL | PCR E_MULTILINE, &errptr, &erroffset, msc_pcre_match_limit, msc_pcre_match_limit_rec ursion); regex = msc_pregcomp_ex(rule->ruleset->mp, rule->op_param, options, &errptr, &erroffset, msc_pcre_match_limit, msc_pcre_match_limit_recursion);
if (regex == NULL) { if (regex == NULL) {
*error_msg = apr_psprintf(rule->ruleset->mp, "Error compiling pattern (o ffset %d): %s", *error_msg = apr_psprintf(rule->ruleset->mp, "Error compiling pattern (o ffset %d): %s",
erroffset, errptr); erroffset, errptr);
return 0; return 0;
} }
rule->op_param_data = regex; rule->op_param_data = regex;
return 1; /* OK */ return 1; /* OK */
} }
skipping to change at line 3348 skipping to change at line 3464
*/ */
static int msre_op_verifySSN_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, char **error_msg) { static int msre_op_verifySSN_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, char **error_msg) {
msc_regex_t *regex = (msc_regex_t *)rule->op_param_data; msc_regex_t *regex = (msc_regex_t *)rule->op_param_data;
const char *target; const char *target;
unsigned int target_length; unsigned int target_length;
char *my_error_msg = NULL; char *my_error_msg = NULL;
int ovector[33]; int ovector[33];
int rc; int rc;
int is_ssn = 0; int is_ssn = 0;
int offset; int offset;
int options = 0;
int matched_bytes = 0; int matched_bytes = 0;
char *qspos = NULL; char *qspos = NULL;
const char *parm = NULL; const char *parm = NULL;
msc_parm *mparm = NULL; msc_parm *mparm = NULL;
#ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT #ifdef WITH_PCRE_JIT
int jit; int jit;
#endif #endif
#endif #endif
skipping to change at line 3371 skipping to change at line 3488
if (regex == NULL) { if (regex == NULL) {
*error_msg = "Internal Error: regex data is null."; *error_msg = "Internal Error: regex data is null.";
return -1; return -1;
} }
memset(ovector, 0, sizeof(ovector)); memset(ovector, 0, sizeof(ovector));
#ifdef WITH_PCRE_STUDY #ifdef WITH_PCRE_STUDY
#ifdef WITH_PCRE_JIT #ifdef WITH_PCRE_JIT
if (msr->txcfg->debuglog_level >= 4) { if (msr->txcfg->debuglog_level >= 4) {
#ifdef WITH_PCRE2
rc = regex->jit_compile_rc;
#else
rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit); rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
#endif
if ((rc != 0) || (jit != 1)) { if ((rc != 0) || (jit != 1)) {
*error_msg = apr_psprintf(msr->mp, *error_msg = apr_psprintf(msr->mp,
"Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - " "Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - "
"Execution error - " "Execution error - "
"Does not support JIT (%d)", "Does not support JIT (%d)",
rule,((rule->actionset != NULL)&&((rule->actionset->id != NU LL)&& rule,((rule->actionset != NULL)&&((rule->actionset->id != NU LL)&&
(rule->actionset->id != NOT_SET_P))) ? rule->actions et->id : "-", (rule->actionset->id != NOT_SET_P))) ? rule->actions et->id : "-",
rule->filename != NULL ? rule->filename : "-", rule->filename != NULL ? rule->filename : "-",
rule->line_num,rc); rule->line_num,rc);
msr_log(msr, 4, "%s.", *error_msg); msr_log(msr, 4, "%s.", *error_msg);
skipping to change at line 3406 skipping to change at line 3527
target_length = var->value_len; target_length = var->value_len;
} }
for (offset = 0; ((unsigned int)offset < target_length) && (is_ssn == 0); of fset++) { for (offset = 0; ((unsigned int)offset < target_length) && (is_ssn == 0); of fset++) {
if (msr->txcfg->debuglog_level >= 9) { if (msr->txcfg->debuglog_level >= 9) {
if (offset > 0) { if (offset > 0) {
msr_log(msr, 9, "Continuing SSN# search at target offset %d.", o ffset); msr_log(msr, 9, "Continuing SSN# search at target offset %d.", o ffset);
} }
} }
rc = msc_regexec_ex(regex, target, target_length, offset, PCRE_NOTEMPTY, #ifdef WITH_PCRE2
ovector, 30, &my_error_msg); options = PCRE2_NOTEMPTY;
#else
options = PCRE_NOTEMPTY;
#endif
rc = msc_regexec_ex(regex, target, target_length, offset, options, ovect
or, 30, &my_error_msg);
/* If there was no match, then we are done. */ /* If there was no match, then we are done. */
#ifdef WITH_PCRE2
if (rc == PCRE2_ERROR_NOMATCH) {
#else
if (rc == PCRE_ERROR_NOMATCH) { if (rc == PCRE_ERROR_NOMATCH) {
#endif
break; break;
} }
if (rc < -1) { if (rc < -1) {
*error_msg = apr_psprintf(msr->mp, "SSN# regex execution failed: %s" , my_error_msg); *error_msg = apr_psprintf(msr->mp, "SSN# regex execution failed: %s" , my_error_msg);
return -1; return -1;
} }
/* Verify a match. */ /* Verify a match. */
if (rc > 0) { if (rc > 0) {
 End of changes. 56 change blocks. 
26 lines changed or deleted 151 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)