]> granicus.if.org Git - php/commitdiff
Fix str len in stripos when $offset argument is given
authorArnaud Le Blanc <lbarnaud@php.net>
Sun, 14 Sep 2008 14:56:34 +0000 (14:56 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Sun, 14 Sep 2008 14:56:34 +0000 (14:56 +0000)
ext/standard/string.c

index fffb91f8b40d3f05a7b41ec2a90a32705ea98cfa..ded24e001beac62cf35811d7e8ae2ce1effc4eb6 100644 (file)
@@ -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;