From f90bb0e967bc8b084ab2d768aed19c1e76166eb8 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Wed, 30 May 2007 09:16:29 +0000 Subject: [PATCH] check length only when it's specified add the same check to fgetss() --- ext/standard/file.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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; -- 2.40.0