[php-src] PR #16700: Fix GH-16695: phar:// tar parser and zero-length file header blocks
| From: | nielsdos | Date: | Mon, 04 Nov 2024 20:23:50 +0000 |
| Subject: | [php-src] PR #16700: Fix GH-16695: phar:// tar parser and zero-length file header blocks | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-29513@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/16700
Author: nielsdos
There are two issues:
1) There's an off-by-one in the check for the minimum file size for a
tar (i.e.
> instead of >=).
2) The loop in the tar parsing parses a header, and then unconditionally
reads the next one. However, that doesn't necessarily exist.
Instead, we remove the loop condition and check for the end of the
file before reading the next header. Note that we can't use
php_stream_eof as the flag may not be set yet when we're already at
the end.