]> granicus.if.org Git - php/commitdiff
fix #41430 (Fatal error with negative values of maxlen parameter of file_get_contents())
authorAntony Dovgal <tony2001@php.net>
Fri, 18 May 2007 12:05:55 +0000 (12:05 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 18 May 2007 12:05:55 +0000 (12:05 +0000)
ext/standard/file.c

index f567fa89c10bc5279475d60244c97459c32b0e2e..66bca30904f5ff6f7dcff405b134c8775a82dd5a 100644 (file)
@@ -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);