Skip to content

Commit 4776c86

Browse files
committed
ext/phar: add upper-bound check on LongLink entry size
1 parent c54c15c commit 4776c86

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ PHP NEWS
8181
PDOStatement::setFetchMode). (SakiTakamachi)
8282

8383
- Phar:
84+
. Fixed bug GH-22556 (OOM DoS via oversized ././@LongLink entry in TAR phar).
85+
(crystarm)
8486
. Fixed bug GH-23418 (Use-after-free when looking up mounted directories).
8587
(Weilin Du)
8688
. Fixed bug GH-23477 (Memory leak on duplicate native Phar manifest entries).

ext/phar/tar.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,9 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
365365
/* support the ././@LongLink system for storing long filenames */
366366
entry.filename_len = entry.uncompressed_filesize;
367367

368-
/* Check for overflow - bug 61065 */
369-
if (entry.filename_len == UINT_MAX || entry.filename_len == 0) {
368+
/* Check for empty or excessively large ././@LongLink filename entries - bug 61065 */
369+
if (entry.filename_len == 0
370+
|| entry.filename_len > UINT16_MAX) {
370371
if (error) {
371372
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (invalid entry size)", fname);
372373
}

0 commit comments

Comments
 (0)