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.4.0alpha1~191^2~87 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a8c917c377281819cd14a5fbf9132d2ac11cbef;p=php Fixed bug #54454 (substr_compare incorrectly reports equality in some cases) --- diff --git a/ext/standard/string.c b/ext/standard/string.c index 1aae38ccab..5eb0411b18 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -5252,10 +5252,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)