Skip to content

Commit c718fd1

Browse files
committed
Avoid overflow
1 parent 1c1df0d commit c718fd1

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
@@ -1772,7 +1772,7 @@ PHPAPI PHP_FUNCTION(fread)
17721772
/* needed because recv/read/gzread doesnt put a null at the end*/
17731773
Z_STRVAL_P(return_value)[Z_STRLEN_P(return_value)] = 0;
17741774

1775-
if (len > Z_STRLEN_P(return_value) * 2) {
1775+
if (Z_STRLEN_P(return_value) < len / 2) {
17761776
Z_STR_P(return_value) = zend_string_truncate(Z_STR_P(return_value), Z_STRLEN_P(return_value), 0);
17771777
}
17781778
}

0 commit comments

Comments
 (0)