From f8217712a4c1f88bbeeeedbea8a6852a6b81721c Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 30 Jul 2007 14:22:06 +0000 Subject: [PATCH] Fixed bug #42142 (substr_replace() returns FALSE when length > string length). [doc] Adjust length validation check inside substr_replace() to be similar to that inside substr() so that excessive length is truncated to string length. --- NEWS | 2 ++ ext/standard/string.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 3eae7a5ab0..054d8cc093 100644 --- a/NEWS +++ b/NEWS @@ -70,6 +70,8 @@ PHP NEWS - Fixed PECL bug #11216 (crash in ZipArchive::addEmptyDir when a directory already exists). (Pierre) +- Fixed bug #42142 (substr_replace() returns FALSE when length > string + length). (Ilia) - Fixed bug #42135 (Second call of session_start() causes creation of SID). (Ilia) - Fixed Bug #42112 (deleting a node produces memory corruption). (Rob) diff --git a/ext/standard/string.c b/ext/standard/string.c index 4436b5a7aa..2617c681b3 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2226,7 +2226,7 @@ PHP_FUNCTION(substr_replace) if (f > Z_STRLEN_PP(str) || (f < 0 && -f > Z_STRLEN_PP(str))) { RETURN_FALSE; } else if (l > Z_STRLEN_PP(str) || (l < 0 && -l > Z_STRLEN_PP(str))) { - RETURN_FALSE; + l = Z_STRLEN_PP(str); } if ((f + l) > Z_STRLEN_PP(str)) { -- 2.40.0