From: Antony Dovgal Date: Fri, 18 May 2007 12:06:44 +0000 (+0000) Subject: MFH: fix #41430 (Fatal error with negative values of maxlen parameter of file_get_con... X-Git-Tag: php-5.2.3RC1~60 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6d41d020dfd2f84618357909232007c6ab3451f1;p=php MFH: fix #41430 (Fatal error with negative values of maxlen parameter of file_get_contents()) --- diff --git a/NEWS b/NEWS index 705cb2bd54..24bc28fb6b 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,8 @@ PHP NEWS - Fixed altering $this via argument named "this". (Dmitry) - Fixed PHP CLI to use the php.ini from the binary location. (Hannes) - Fixed segfault in strripos(). (Tony, Joxean Koret) +- Fixed bug #41430 (Fatal error with negative values of maxlen parameter of + file_get_contents()). (Tony) - Fixed bug #41421 (Uncaught exception from a stream wrapper segfaults). (Tony, Dmitry) - Fixed bug #41403 (json_decode cannot decode floats if localeconv diff --git a/ext/standard/file.c b/ext/standard/file.c index 993842e17a..1b61f17804 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -545,6 +545,11 @@ PHP_FUNCTION(file_get_contents) RETURN_FALSE; } + if (maxlen < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length must be greater than or equal to zero"); + RETURN_FALSE; + } + if (offset > 0 && php_stream_seek(stream, offset, SEEK_SET) < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", offset); php_stream_close(stream);