mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
check length only when it's specified
add the same check to fgetss()
This commit is contained in:
parent
56fcde4f4a
commit
f90bb0e967
1 changed files with 7 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue