From: Antony Dovgal Date: Fri, 18 May 2007 20:34:07 +0000 (+0000) Subject: fix leak and check for < 0 only of the 5th arg was passed X-Git-Tag: RELEASE_1_4~131 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b56ff03b48edc53b4b05398862fa48608fc9f12;p=php fix leak and check for < 0 only of the 5th arg was passed --- diff --git a/ext/standard/file.c b/ext/standard/file.c index 66bca30904..1f81380c29 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -554,6 +554,11 @@ PHP_FUNCTION(file_get_contents) return; } + if (ZEND_NUM_ARGS() == 5 && maxlen < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "length must be greater than or equal to zero"); + RETURN_FALSE; + } + context = php_stream_context_from_zval(zcontext, 0); if (php_stream_path_param_encode(ppfilename, &filename, &filename_len, REPORT_ERRORS, context) == FAILURE) { RETURN_FALSE; @@ -566,11 +571,6 @@ 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);