@@ -66,6 +66,7 @@ static int fetch_target_exception(msre_rule *rule, modsec_rec *msr, msre_var *va
66
66
char * errptr ;
67
67
int erroffset ;
68
68
int match = 0 ;
69
+ size_t value_len ;
69
70
70
71
if (msr == NULL )
71
72
return 0 ;
@@ -114,12 +115,17 @@ static int fetch_target_exception(msre_rule *rule, modsec_rec *msr, msre_var *va
114
115
value = NULL ;
115
116
}
116
117
118
+ value_len = 0 ;
119
+ if (value != NULL ) {
120
+ value_len = strlen (value );
121
+ }
122
+
117
123
if ((strlen (myname ) == strlen (name )) &&
118
- (strncasecmp (myname , name ,strlen (myname )) == 0 )) {
124
+ (strncasecmp (myname , name , strlen (myname )) == 0 )) {
119
125
120
126
if (value != NULL && myvalue != NULL ) {
121
- if (strlen ( value ) > 2 && value [0 ] == '/' && value [strlen ( value ) - 1 ] == '/' ) {
122
- value [strlen ( value ) - 1 ] = '\0' ;
127
+ if (value_len > 2 && value [0 ] == '/' && value [value_len - 1 ] == '/' ) {
128
+ value [value_len - 1 ] = '\0' ;
123
129
#ifdef WITH_PCRE2
124
130
regex = msc_pregcomp (msr -> mp , value + 1 ,
125
131
PCRE2_DOTALL | PCRE2_CASELESS | PCRE2_DOLLAR_ENDONLY , (const char * * )& errptr , & erroffset );
@@ -154,7 +160,7 @@ static int fetch_target_exception(msre_rule *rule, modsec_rec *msr, msre_var *va
154
160
match = 1 ;
155
161
}
156
162
}
157
- } else if ((strlen (myvalue ) == strlen ( value ) ) &&
163
+ } else if ((strlen (myvalue ) == value_len ) &&
158
164
strncasecmp (myvalue ,value ,strlen (myvalue )) == 0 ) {
159
165
if (msr -> txcfg -> debuglog_level >= 9 ) {
160
166
msr_log (msr , 9 , "fetch_target_exception: Target %s will not be processed." , target );
0 commit comments