Skip to content

Commit 857ac7f

Browse files
authored
ext/phar: add upper-bound check on LongLink entry size (#24423)
1 parent 9471a18 commit 857ac7f

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎NEWS‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ PHP NEWS
9696
. Reverted the validity check on the flags argument of posix_access().
9797
(David Carlier)
9898

99+
- Phar:
100+
. Fixed bug GH-22556 (OOM DoS via oversized ././@LongLink entry in TAR phar).
101+
(crystarm)
102+
99103
- Readline:
100104
. Fixed a heap over-read in the interactive shell prompt when cli.prompt is
101105
set to an empty string. (Ilia Alshanetsky)

‎ext/phar/tar.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,10 @@ zend_result phar_parse_tarfile(
441441
last_was_longlink = true;
442442
/* support the ././@LongLink system for storing long filenames */
443443

444-
/* Check for overflow - bug 61065 */
445-
if (entry.uncompressed_filesize == 0 || entry.uncompressed_filesize > totalsize) {
444+
/* Check for empty, truncated, or excessively large ././@LongLink filename entries - bug 61065 */
445+
if (entry.uncompressed_filesize == 0
446+
|| entry.uncompressed_filesize > totalsize
447+
|| entry.uncompressed_filesize > UINT16_MAX) {
446448
if (error) {
447449
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (invalid entry size)", fname);
448450
}

0 commit comments

Comments
 (0)