]> granicus.if.org Git - php/commitdiff
fix #41516 (fgets() returns a line of text when length parameter is <= 0)
authorAntony Dovgal <tony2001@php.net>
Tue, 29 May 2007 20:48:38 +0000 (20:48 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 29 May 2007 20:48:38 +0000 (20:48 +0000)
ext/standard/file.c

index 1f81380c292059761b1c5304890572a5a00d9013..89896dd7bca3b2b69d360da38744d41c6f6471e0 100644 (file)
@@ -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;