From: Pierrick Charron Date: Sun, 3 Apr 2011 07:18:27 +0000 (+0000) Subject: Fixed bug #54454 (substr_compare incorrectly reports equality in some cases) X-Git-Tag: php-5.3.7RC1~196 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4919f3286b76865c11d0dd651bc1be6b61ff00e5;p=php Fixed bug #54454 (substr_compare incorrectly reports equality in some cases) --- diff --git a/NEWS b/NEWS index 463e765cd5..1ca5022ce7 100644 --- a/NEWS +++ b/NEWS @@ -9,10 +9,13 @@ PHP NEWS - Core: . Fixed a crash inside dtor for error handling. (Ilia) + . Fixed bug #54454 (substr_compare incorrectly reports equality in some + cases). (Pierrick) . Fixed bug #54180 (parse_url() incorrectly parses path when ? in fragment). (tomas dot brastavicius at quantum dot lt, Pierrick) - . Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using - TMPDIR on Windows). (Pierre) + . Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using + TMPDIR on Windows). (Pierre) + - cURL . Added CURLINFO_REDIRECT_URL support. (Daniel Stenberg, Pierre) diff --git a/ext/standard/string.c b/ext/standard/string.c index 7208d86779..9dd99cefa2 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -5243,10 +5243,6 @@ PHP_FUNCTION(substr_compare) RETURN_FALSE; } - if (len > s1_len - offset) { - len = s1_len - offset; - } - cmp_len = (uint) (len ? len : MAX(s2_len, (s1_len - offset))); if (!cs) { diff --git a/ext/standard/tests/strings/bug54454.phpt b/ext/standard/tests/strings/bug54454.phpt new file mode 100644 index 0000000000..88835c983b --- /dev/null +++ b/ext/standard/tests/strings/bug54454.phpt @@ -0,0 +1,8 @@ +--TEST-- +Bug #54454 (substr_compare incorrectly reports equality in some cases) +--FILE-- + +--EXPECT-- +int(-3) diff --git a/ext/standard/tests/strings/substr_compare.phpt b/ext/standard/tests/strings/substr_compare.phpt index 206ccd5ede..c647506b53 100644 --- a/ext/standard/tests/strings/substr_compare.phpt +++ b/ext/standard/tests/strings/substr_compare.phpt @@ -27,7 +27,7 @@ int(-1) Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d bool(false) -int(0) +int(-1) Warning: substr_compare() expects parameter 5 to be boolean, object given in %s on line %d bool(false)