Skip to content

Commit 9762c44

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: zip: Don't truncate return value of zip_fread() with user sizes
2 parents e929602 + a21783c commit 9762c44

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

ext/zip/php_zip.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,6 @@ PHP_FUNCTION(zip_entry_read)
13031303
zend_long len = 0;
13041304
zip_read_rsrc * zr_rsrc;
13051305
zend_string *buffer;
1306-
int n = 0;
13071306

13081307
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &zip_entry, &len) == FAILURE) {
13091308
RETURN_THROWS();
@@ -1319,7 +1318,7 @@ PHP_FUNCTION(zip_entry_read)
13191318

13201319
if (zr_rsrc->zf) {
13211320
buffer = zend_string_safe_alloc(1, len, 0, false);
1322-
n = zip_fread(zr_rsrc->zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
1321+
zip_int64_t n = zip_fread(zr_rsrc->zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
13231322
if (n > 0) {
13241323
ZSTR_VAL(buffer)[n] = '\0';
13251324
ZSTR_LEN(buffer) = n;
@@ -2781,8 +2780,6 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
27812780
zend_string *filename;
27822781
zend_string *buffer;
27832782

2784-
int n = 0;
2785-
27862783
if (type == 1) {
27872784
if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|ll", &filename, &len, &flags) == FAILURE) {
27882785
RETURN_THROWS();
@@ -2819,7 +2816,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
28192816
}
28202817

28212818
buffer = zend_string_safe_alloc(1, len, 0, false);
2822-
n = zip_fread(zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
2819+
zip_int64_t n = zip_fread(zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
28232820
if (n < 1) {
28242821
zend_string_efree(buffer);
28252822
RETURN_EMPTY_STRING();

0 commit comments

Comments
 (0)