Skip to content

Commit 2d88b2a

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Avoid overflow
2 parents 1ab03bc + c718fd1 commit 2d88b2a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ext/standard/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1816,7 +1816,7 @@ PHPAPI PHP_FUNCTION(fread)
18161816
/* needed because recv/read/gzread doesnt put a null at the end*/
18171817
Z_STRVAL_P(return_value)[Z_STRLEN_P(return_value)] = 0;
18181818

1819-
if (len > Z_STRLEN_P(return_value) * 2) {
1819+
if (Z_STRLEN_P(return_value) < len / 2) {
18201820
Z_STR_P(return_value) = zend_string_truncate(Z_STR_P(return_value), Z_STRLEN_P(return_value), 0);
18211821
}
18221822
}

0 commit comments

Comments
 (0)