From: Arnaud Le Blanc Date: Sun, 14 Sep 2008 14:56:34 +0000 (+0000) Subject: Fix str len in stripos when $offset argument is given X-Git-Tag: BEFORE_HEAD_NS_CHANGE~393 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8225d21a2d0bcf65d70fd4a4572e0d0199b19884;p=php Fix str len in stripos when $offset argument is given --- diff --git a/ext/standard/string.c b/ext/standard/string.c index fffb91f8b4..ded24e001b 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2664,7 +2664,7 @@ PHP_FUNCTION(stripos) if (Z_TYPE_PP(haystack) == IS_UNICODE) { /* calculate code unit offset */ U16_FWD_N(Z_USTRVAL_PP(haystack), cu_offset, haystack_len, offset); - found = php_u_stristr(Z_USTRVAL_PP(haystack) + cu_offset, Z_USTRVAL_PP(needle), haystack_len, needle_len, 1 TSRMLS_CC); + found = php_u_stristr(Z_USTRVAL_PP(haystack) + cu_offset, Z_USTRVAL_PP(needle), haystack_len - cu_offset, needle_len, 1 TSRMLS_CC); } else { haystack_dup = estrndup(Z_STRVAL_PP(haystack), haystack_len); php_strtolower((char *)haystack_dup, haystack_len); @@ -2686,7 +2686,7 @@ PHP_FUNCTION(stripos) /* calculate code unit offset */ U16_FWD_N(Z_USTRVAL_PP(haystack), cu_offset, haystack_len, offset); found = php_u_stristr(Z_USTRVAL_PP(haystack) + cu_offset, - u_needle_char, haystack_len, needle_len, 1 TSRMLS_CC); + u_needle_char, haystack_len - cu_offset, needle_len, 1 TSRMLS_CC); } else { c = tolower((char)Z_LVAL_PP(needle)); needle_char[0] = c;