|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-12-05 14:00 UTC] ant@php.net
Description: ------------ Take a look at the mb_stristr_basic.phpt test just checked into 5.3/6.0. The test passes fine on 5.2 and fails on 5.3 and 6.0. Reproduce code: --------------- ext/mbstring/tests/mb_stristr_basic.phpt Expected result: ---------------- *** Testing mb_stristr() : basic functionality *** -- ASCII string: needle exists -- string(10) "6263646566" string(10) "6263646566" string(2) "61" -- ASCII string: needle doesn't exist -- bool(false) -- Multibyte string: needle exists -- string(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89" string(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89" string(44) "ceb1ceb2ceb3ceb4ceb5ceb6ceb7ceb8ceb9cebacebb" -- Multibyte string: needle doesn't exist -- bool(false) ===DONE=== Actual result: -------------- *** Testing mb_stristr() : basic functionality *** -- ASCII string: needle exists -- string(10) "6263646566" string(10) "6263646566" string(2) "61" -- ASCII string: needle doesn't exist -- string(6) "abcdef" -- Multibyte string: needle exists -- string(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89" string(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89" string(44) "ceb1ceb2ceb3ceb4ceb5ceb6ceb7ceb8ceb9cebacebb" -- Multibyte string: needle doesn't exist -- string(48) "αβγδεζηθικλμνξοπρστυφχψω" ===DONE=== PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
In the file mbstring.c on function mb_stristr the variable 'n' used to determine the position of needle on haystack was changed from signed int to unsignedint. When the php_mb_stripos function does not find needle in haystack it returns -1 to n. As n is unsigned, that value will be huge, causing the problem. Here is a simple patch that might fix the issue. Index: ext/mbstring/mbstring.c =================================================================== RCS file: /repository/php-src/ext/mbstring/mbstring.c,v retrieving revision 1.224.2.22.2.25.2.41 diff -u -u -w -p -r1.224.2.22.2.25.2.41 mbstring.c --- ext/mbstring/mbstring.c 27 Dec 2008 13:32:24 -0000 1.224.2.22.2.25.2.41 +++ ext/mbstring/mbstring.c 30 Dec 2008 00:58:31 -0000 @@ -2555,7 +2555,8 @@ PHP_FUNCTION(mb_strrchr) PHP_FUNCTION(mb_stristr) { zend_bool part = 0; - unsigned int n, from_encoding_len, len, mblen; + unsigned from_encoding_len, len, mblen; + int n; mbfl_string haystack, needle, result, *ret = NULL; const char *from_encoding = mbfl_no2preferred_mime_name(MBSTRG(current_internal_encoding)); mbfl_string_init(&haystack);