From: Antony Dovgal Date: Wed, 30 May 2007 09:16:29 +0000 (+0000) Subject: check length only when it's specified X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND~578 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f90bb0e967bc8b084ab2d768aed19c1e76166eb8;p=php check length only when it's specified add the same check to fgetss() --- diff --git a/ext/standard/file.c b/ext/standard/file.c index 89896dd7bc..b1c7bae415 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1135,10 +1135,10 @@ PHPAPI PHP_FUNCTION(fgets) size_t retlen = 0; if (zend_parse_parameters(argc TSRMLS_CC, "r|l", &zstream, &length) == FAILURE) { - RETURN_NULL(); + return; } - if (length <= 0) { + if (ZEND_NUM_ARGS() == 2 && length <= 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than 0"); RETURN_FALSE; } @@ -1210,6 +1210,11 @@ PHPAPI PHP_FUNCTION(fgetss) return; } + if (ZEND_NUM_ARGS() >= 2 && length <= 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than 0"); + RETURN_FALSE; + } + if (length == 1) { /* For BC reasons, fgetss() should only return length-1 bytes. */ RETURN_FALSE;