Skip to content

Commit ed94ba5

Browse files
committed
Add missing checks for php_crc32_stream_bulk_update() in phar
1 parent c617afd commit ed94ba5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

ext/phar/phar.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2801,7 +2801,16 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv
28012801
return EOF;
28022802
}
28032803
newcrc32 = php_crc32_bulk_init();
2804-
php_crc32_stream_bulk_update(&newcrc32, file, entry->uncompressed_filesize);
2804+
if (php_crc32_stream_bulk_update(&newcrc32, file, entry->uncompressed_filesize) != SUCCESS) {
2805+
if (closeoldfile) {
2806+
php_stream_close(oldfile);
2807+
}
2808+
php_stream_close(newfile);
2809+
if (error) {
2810+
spprintf(error, 0, "unable to read file \"%s\" for crc32 while creating new phar \"%s\"", entry->filename, phar->fname);
2811+
}
2812+
return EOF;
2813+
}
28052814
entry->crc32 = php_crc32_bulk_end(newcrc32);
28062815
entry->is_crc_checked = 1;
28072816
if (!(entry->flags & PHAR_ENT_COMPRESSION_MASK)) {

ext/phar/zip.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,10 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{
939939
efp = phar_get_efp(entry, 0);
940940
newcrc32 = php_crc32_bulk_init();
941941

942-
php_crc32_stream_bulk_update(&newcrc32, efp, entry->uncompressed_filesize);
942+
if (php_crc32_stream_bulk_update(&newcrc32, efp, entry->uncompressed_filesize) != SUCCESS) {
943+
spprintf(p->error, 0, "unable to read file \"%s\" for crc32 in zip-based phar \"%s\"", entry->filename, entry->phar->fname);
944+
return ZEND_HASH_APPLY_STOP;
945+
}
943946

944947
entry->crc32 = php_crc32_bulk_end(newcrc32);
945948
PHAR_SET_32(central.uncompsize, entry->uncompressed_filesize);

0 commit comments

Comments
 (0)