Skip to content

Commit 1fdece5

Browse files
committed
fix bug #61065
1 parent e6dc487 commit 1fdece5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ext/phar/tar.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,16 @@ int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias,
337337
last_was_longlink = 1;
338338
/* support the ././@LongLink system for storing long filenames */
339339
entry.filename_len = entry.uncompressed_filesize;
340+
341+
/* Check for overflow - bug 61065 */
342+
if (entry.filename_len == UINT_MAX) {
343+
if (error) {
344+
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (invalid entry size)", fname);
345+
}
346+
php_stream_close(fp);
347+
phar_destroy_phar_data(myphar TSRMLS_CC);
348+
return FAILURE;
349+
}
340350
entry.filename = pemalloc(entry.filename_len+1, myphar->is_persistent);
341351

342352
read = php_stream_read(fp, entry.filename, entry.filename_len);

0 commit comments

Comments
 (0)