@@ -91,7 +91,7 @@ map_op_to_str_eq_flags(tfw_http_match_op_t op)
9191}
9292
9393bool
94- tfw_match_regex (tfw_match_t op , const char * cstr , size_t len , const TfwStr * arg )
94+ tfw_match_regex (const char * cstr , const TfwStr * arg )
9595{
9696 bool result ;
9797 int r ;
@@ -117,7 +117,7 @@ tfw_rule_str_match(const TfwStr *str, const char *cstr,
117117 cstr , cstr_len , flags );
118118
119119 if (op == TFW_HTTP_MATCH_O_REGEX )
120- return tfw_match_regex (op , cstr , cstr_len , str );
120+ return tfw_match_regex (cstr , str );
121121
122122 return tfw_str_eq_cstr (str , cstr , cstr_len , flags );
123123}
@@ -371,7 +371,7 @@ __cmp_hdr_raw_value(const TfwStr *chunk, const TfwStr *end, const TfwStr *hdr,
371371 rhdr .chunks += cnum ;
372372 rhdr .nchunks -= cnum ;
373373 rhdr .len -= name_len ;
374- return tfw_match_regex (rule -> op , p_val , p_val_len , & rhdr );
374+ return tfw_match_regex (p_val , & rhdr );
375375 }
376376
377377 return __cmp_hdr_raw_value_str (chunk , end , p_val , p_val_len , flags ,
@@ -830,8 +830,23 @@ write_regex(const char *arg)
830830 int len = strlen (arg );
831831 int len1 ;
832832
833- if (len < sizeof (unsigned short )) {
834- T_ERR_NL ("String of regex too short\n" );
833+ /*
834+ * Length of regexp string must be greater or equal to sizeof(number_of_regex)
835+ * because we use memory allocated for this string for storing id
836+ * of the regexp.
837+ */
838+ if (len < sizeof (number_of_regex )) {
839+ T_ERR_NL ("String of regex too short.\n" );
840+ return - EINVAL ;
841+ }
842+
843+ if (number_of_db_regex == USHRT_MAX ) {
844+ T_ERR_NL ("Maximum number of regular expression databases has been reached.\n" );
845+ return - EINVAL ;
846+ }
847+
848+ if (number_of_regex == USHRT_MAX ) {
849+ T_ERR_NL ("Maximum number of regular expressions has been reached.\n" );
835850 return - EINVAL ;
836851 }
837852
0 commit comments