This commit is contained in:
Nikita Popov 2019-04-08 11:40:50 +02:00
parent eea61cda7d
commit d7b5954f28
4 changed files with 24 additions and 4 deletions

2
NEWS
View File

@ -32,6 +32,8 @@ PHP NEWS
(Vlad Temian)
. Fixed bug #77844 (Crash due to null pointer in parse_ini_string with
INI_SCANNER_TYPED). (Nikita)
. Fixed bug #77853 (Inconsistent substr_compare behaviour with empty
haystack). (Nikita)
04 Apr 2019, PHP 7.2.17

View File

@ -5739,7 +5739,7 @@ PHP_FUNCTION(substr_compare)
offset = (offset < 0) ? 0 : offset;
}
if ((size_t)offset >= ZSTR_LEN(s1)) {
if ((size_t)offset > ZSTR_LEN(s1)) {
php_error_docref(NULL, E_WARNING, "The start position cannot exceed initial string length");
RETURN_FALSE;
}

View File

@ -0,0 +1,20 @@
--TEST--
Bug #77853: Inconsistent substr_compare behaviour with empty haystack
--FILE--
<?php
var_dump(substr_compare('', '', 0, 0));
var_dump(substr_compare('', '', 0));
var_dump(substr_compare('abc', '', 3, 0));
var_dump(substr_compare('abc', '', 3));
var_dump(substr_compare('abc', "\0", 3));
?>
--EXPECT--
int(0)
int(0)
int(0)
int(0)
int(-1)

View File

@ -27,9 +27,7 @@ int(0)
int(0)
bool(true)
bool(true)
Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d
bool(false)
int(-1)
bool(true)
int(0)