Skip to content

Commit a21783c

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: zip: Don't truncate return value of zip_fread() with user sizes
2 parents 39dc317 + 4eacb6d commit a21783c

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ PHP NEWS
5555

5656
- Zip:
5757
. Fix crash in property existence test. (ndossche)
58+
. Don't truncate return value of zip_fread() with user sizes. (ndossche)
5859

5960
- Zlib:
6061
. Fix assertion failures resulting in crashes with stream filter

ext/zip/php_zip.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,6 @@ PHP_FUNCTION(zip_entry_read)
12901290
zend_long len = 0;
12911291
zip_read_rsrc * zr_rsrc;
12921292
zend_string *buffer;
1293-
int n = 0;
12941293

12951294
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &zip_entry, &len) == FAILURE) {
12961295
RETURN_THROWS();
@@ -1306,7 +1305,7 @@ PHP_FUNCTION(zip_entry_read)
13061305

13071306
if (zr_rsrc->zf) {
13081307
buffer = zend_string_safe_alloc(1, len, 0, 0);
1309-
n = zip_fread(zr_rsrc->zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
1308+
zip_int64_t n = zip_fread(zr_rsrc->zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
13101309
if (n > 0) {
13111310
ZSTR_VAL(buffer)[n] = '\0';
13121311
ZSTR_LEN(buffer) = n;
@@ -2868,8 +2867,6 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
28682867
zend_string *filename;
28692868
zend_string *buffer;
28702869

2871-
int n = 0;
2872-
28732870
if (type == 1) {
28742871
if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|ll", &filename, &len, &flags) == FAILURE) {
28752872
RETURN_THROWS();
@@ -2906,7 +2903,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
29062903
}
29072904

29082905
buffer = zend_string_safe_alloc(1, len, 0, 0);
2909-
n = zip_fread(zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
2906+
zip_int64_t n = zip_fread(zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
29102907
if (n < 1) {
29112908
zend_string_efree(buffer);
29122909
RETURN_EMPTY_STRING();

0 commit comments

Comments
 (0)