[php-src] master: ext/phar: add upper-bound check on LongLink entry size (#24423)
| From: | Georgij Tsarin via GitHub | Date: | Mon, 19 Oct 2026 20:57:54 +0000 |
| Subject: | [php-src] master: ext/phar: add upper-bound check on LongLink entry size (#24423) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142479@lists.php.net to get a copy of this message | ||
Author: Georgij Tsarin (crystarm)
Committer: GitHub (web-flow)
Pusher: ndossche
Date: 2026-10-19T22:57:50+02:00
Commit: https://github.com/php/php-src/commit/857ac7f0b34ea9ba71a3e71f6f5b5048ecdf47a7
Raw diff: https://github.com/php/php-src/commit/857ac7f0b34ea9ba71a3e71f6f5b5048ecdf47a7.diff
ext/phar: add upper-bound check on LongLink entry size (#24423)
Changed paths:
M NEWS
M ext/phar/tar.c
Diff:
diff --git a/NEWS b/NEWS
index 9a23a0f14c64..cbd8903c061f 100644
--- a/NEWS
+++ b/NEWS
@@ -96,6 +96,10 @@ PHP NEWS
. Reverted the validity check on the flags argument of posix_access().
(David Carlier)
+- Phar:
+ . Fixed bug GH-22556 (OOM DoS via oversized ././@LongLink entry in TAR phar).
+ (crystarm)
+
- Readline:
. Fixed a heap over-read in the interactive shell prompt when cli.prompt is
set to an empty string. (Ilia Alshanetsky)
diff --git a/ext/phar/tar.c b/ext/phar/tar.c
index 3ab23c81cc0a..ee27a38478e4 100644
--- a/ext/phar/tar.c
+++ b/ext/phar/tar.c
@@ -441,8 +441,10 @@ zend_result phar_parse_tarfile(
last_was_longlink = true;
/* support the ././@LongLink system for storing long filenames */
- /* Check for overflow - bug 61065 */
- if (entry.uncompressed_filesize == 0 || entry.uncompressed_filesize > totalsize) {
+ /* Check for empty, truncated, or excessively large ././@LongLink filename entries - bug 61065
*/
+ if (entry.uncompressed_filesize == 0
+ || entry.uncompressed_filesize > totalsize
+ || entry.uncompressed_filesize > UINT16_MAX) {
if (error) {
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (invalid
entry size)", fname);
}