From: Antony Dovgal Date: Fri, 18 May 2007 12:05:55 +0000 (+0000) Subject: fix #41430 (Fatal error with negative values of maxlen parameter of file_get_contents()) X-Git-Tag: RELEASE_1_4~142 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb2240d4941ebe5948e5fd69c58c7c7a9a62d65d;p=php fix #41430 (Fatal error with negative values of maxlen parameter of file_get_contents()) --- diff --git a/ext/standard/file.c b/ext/standard/file.c index f567fa89c1..66bca30904 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -566,6 +566,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);