[php-src] PR #25798: Fix PHAR_GET_32 in ext/phar/tar.c reading only 1 byte on little-endian
| From: | hohphu8 | Date: | Thu, 26 Nov 2026 19:16:16 +0000 |
| Subject: | [php-src] PR #25798: Fix PHAR_GET_32 in ext/phar/tar.c reading only 1 byte on little-endian | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41073@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25798
Author: hohphu8
In
phar_parse_tarfile() (ext/phar/tar.c), the little-endian definition of
PHAR_GET_32(buffer) is (uint32_t) *(buffer). Because buffer
is char *, this only reads the first signed char byte instead of a 32-bit
little-endian integer, ignoring the upper 3 bytes of sig_flags in
.phar/signature.bin (and sign-extending values with bit 7 set).
This replaces both #ifdef WORDS_BIGENDIAN branches with a single 4-byte little-endian
read using unsigned char * and explicit uint32_t casts.
Adds ext/phar/tests/tar/tar_sig_flags_32bit.phpt, which corrupts the upper 3 bytes of
sig_flags and checks that verification fails with broken or unsupported
signature. Verified FAIL -> PASS on PHP-8.4 (Debug + ZTS) with
ext/phar/tests/tar/ passing.
*I found this through source inspection with an automated/LLM-assisted tool, then reproduced and
verified it myself.*