11/*
22 * ModSecurity for Apache 2.x, http://www.modsecurity.org/
3- * Copyright (c) 2004-2013 Trustwave Holdings, Inc. (http://www.trustwave.com/)
3+ * Copyright (c) 2004-2022 Trustwave Holdings, Inc. (http://www.trustwave.com/)
44 *
55 * You may not use this file except in compliance with
66 * the License. You may obtain a copy of the License at
@@ -386,7 +386,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
386386 case HASH_URL_HREF_HASH_RX :
387387 if (em [i ]-> type == HASH_URL_HREF_HASH_RX ) {
388388 rc = msc_regexec_capture (em [i ]-> param_data , link , strlen (link ), ovector , 30 , & my_error_msg );
389+ #ifdef WITH_PCRE2
390+ if ((rc == PCRE2_ERROR_MATCHLIMIT ) || (rc == PCRE2_ERROR_RECURSIONLIMIT )) {
391+ #else
389392 if ((rc == PCRE_ERROR_MATCHLIMIT ) || (rc == PCRE_ERROR_RECURSIONLIMIT )) {
393+ #endif
390394 msc_string * s = (msc_string * )apr_pcalloc (msr -> mp , sizeof (msc_string ));
391395
392396 if (s == NULL ) return -1 ;
@@ -415,7 +419,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
415419 msr_log (msr , 4 , "%s." , error_msg );
416420 return -1 ;
417421 }
422+ #ifdef WITH_PCRE2
423+ if (rc != PCRE2_ERROR_NOMATCH ) { /* Match. */
424+ #else
418425 if (rc != PCRE_ERROR_NOMATCH ) { /* Match. */
426+ #endif
419427 return 1 ;
420428 }
421429 }
@@ -441,7 +449,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
441449 case HASH_URL_FACTION_HASH_RX :
442450 if (em [i ]-> type == HASH_URL_FACTION_HASH_RX ) {
443451 rc = msc_regexec_capture (em [i ]-> param_data , link , strlen (link ), ovector , 30 , & my_error_msg );
452+ #ifdef WITH_PCRE2
453+ if ((rc == PCRE2_ERROR_MATCHLIMIT ) || (rc == PCRE2_ERROR_RECURSIONLIMIT )) {
454+ #else
444455 if ((rc == PCRE_ERROR_MATCHLIMIT ) || (rc == PCRE_ERROR_RECURSIONLIMIT )) {
456+ #endif
445457 msc_string * s = (msc_string * )apr_pcalloc (msr -> mp , sizeof (msc_string ));
446458
447459 if (s == NULL ) return -1 ;
@@ -470,7 +482,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
470482 msr_log (msr , 4 , "%s." , error_msg );
471483 return -1 ;
472484 }
485+ #ifdef WITH_PCRE2
486+ if (rc != PCRE2_ERROR_NOMATCH ) { /* Match. */
487+ #else
473488 if (rc != PCRE_ERROR_NOMATCH ) { /* Match. */
489+ #endif
474490 return 1 ;
475491 }
476492 }
@@ -496,7 +512,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
496512 case HASH_URL_LOCATION_HASH_RX :
497513 if (em [i ]-> type == HASH_URL_LOCATION_HASH_RX ) {
498514 rc = msc_regexec_capture (em [i ]-> param_data , link , strlen (link ), ovector , 30 , & my_error_msg );
515+ #ifdef WITH_PCRE2
516+ if ((rc == PCRE2_ERROR_MATCHLIMIT ) || (rc == PCRE2_ERROR_RECURSIONLIMIT )) {
517+ #else
499518 if ((rc == PCRE_ERROR_MATCHLIMIT ) || (rc == PCRE_ERROR_RECURSIONLIMIT )) {
519+ #endif
500520 msc_string * s = (msc_string * )apr_pcalloc (msr -> mp , sizeof (msc_string ));
501521
502522 if (s == NULL ) return -1 ;
@@ -525,7 +545,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
525545 msr_log (msr , 4 , "%s." , error_msg );
526546 return -1 ;
527547 }
548+ #ifdef WITH_PCRE2
549+ if (rc != PCRE2_ERROR_NOMATCH ) { /* Match. */
550+ #else
528551 if (rc != PCRE_ERROR_NOMATCH ) { /* Match. */
552+ #endif
529553 return 1 ;
530554 }
531555 }
@@ -551,7 +575,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
551575 case HASH_URL_IFRAMESRC_HASH_RX :
552576 if (em [i ]-> type == HASH_URL_IFRAMESRC_HASH_RX ) {
553577 rc = msc_regexec_capture (em [i ]-> param_data , link , strlen (link ), ovector , 30 , & my_error_msg );
578+ #ifdef WITH_PCRE2
579+ if ((rc == PCRE2_ERROR_MATCHLIMIT ) || (rc == PCRE2_ERROR_RECURSIONLIMIT )) {
580+ #else
554581 if ((rc == PCRE_ERROR_MATCHLIMIT ) || (rc == PCRE_ERROR_RECURSIONLIMIT )) {
582+ #endif
555583 msc_string * s = (msc_string * )apr_pcalloc (msr -> mp , sizeof (msc_string ));
556584
557585 if (s == NULL ) return -1 ;
@@ -580,7 +608,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
580608 msr_log (msr , 4 , "%s." , error_msg );
581609 return -1 ;
582610 }
611+ #ifdef WITH_PCRE2
612+ if (rc != PCRE2_ERROR_NOMATCH ) { /* Match. */
613+ #else
583614 if (rc != PCRE_ERROR_NOMATCH ) { /* Match. */
615+ #endif
584616 return 1 ;
585617 }
586618 }
@@ -606,7 +638,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
606638 case HASH_URL_FRAMESRC_HASH_RX :
607639 if (em [i ]-> type == HASH_URL_FRAMESRC_HASH_RX ) {
608640 rc = msc_regexec_capture (em [i ]-> param_data , link , strlen (link ), ovector , 30 , & my_error_msg );
641+ #ifdef WITH_PCRE2
642+ if ((rc == PCRE2_ERROR_MATCHLIMIT ) || (rc == PCRE2_ERROR_RECURSIONLIMIT )) {
643+ #else
609644 if ((rc == PCRE_ERROR_MATCHLIMIT ) || (rc == PCRE_ERROR_RECURSIONLIMIT )) {
645+ #endif
610646 msc_string * s = (msc_string * )apr_pcalloc (msr -> mp , sizeof (msc_string ));
611647
612648 if (s == NULL ) return -1 ;
@@ -635,7 +671,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
635671 msr_log (msr , 4 , "%s." , error_msg );
636672 return -1 ;
637673 }
674+ #ifdef WITH_PCRE2
675+ if (rc != PCRE2_ERROR_NOMATCH ) { /* Match. */
676+ #else
638677 if (rc != PCRE_ERROR_NOMATCH ) { /* Match. */
678+ #endif
639679 return 1 ;
640680 }
641681 }
0 commit comments