From 7b5215d83ac9b79e41b8b21f60814ea626670a79 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Tue, 29 May 2007 20:48:38 +0000 Subject: fix #41516 (fgets() returns a line of text when length parameter is <= 0) --- ext/standard/file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ext/standard/file.c b/ext/standard/file.c index 1f81380c29..89896dd7bc 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1138,6 +1138,11 @@ PHPAPI PHP_FUNCTION(fgets) RETURN_NULL(); } + if (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, fgets() should only return length-1 bytes. */ RETURN_FALSE; -- cgit v1.2.1