Repository navigation
Conversation
LamentXU123
requested changes
Nov 27, 2026
Member
There was a problem hiding this comment.
I would suggest you to validate the three "corrupted" high bits seperately in the test?
| $pos = strpos($raw, ".phar/signature.bin\0"); | ||
| $dataOff = $pos + 512; | ||
|
|
||
| // Corrupt upper 3 bytes of 32-bit sig_flags (0x03000000 -> 0x03ffffff) |
Member
There was a problem hiding this comment.
Is it clearer to make the comment "03 00 00 00 -> 03 ff ff ff"?
Contributor
Author
There was a problem hiding this comment.
Updated as suggested. Thanks!
hohphu8
force-pushed
the
fix-phar-tar-sig-flags-32bit
branch
from
November 27, 2026 12:05
5c7803e to
5a131f0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
phar_parse_tarfile()(ext/phar/tar.c), the little-endian definition ofPHAR_GET_32(buffer)is(uint32_t) *(buffer). Becausebufferischar *, this only reads the first signedcharbyte instead of a 32-bit little-endian integer, ignoring the upper 3 bytes ofsig_flagsin.phar/signature.bin(and sign-extending values with bit 7 set).This replaces both
#ifdef WORDS_BIGENDIANbranches with a single 4-byte little-endian read usingunsigned char *and explicituint32_tcasts.Adds
ext/phar/tests/tar/tar_sig_flags_32bit.phpt, which corrupts the upper 3 bytes ofsig_flagsand checks that verification fails withbroken or unsupported signature. VerifiedFAIL -> PASSonPHP-8.4(Debug + ZTS) withext/phar/tests/tar/passing.I found this through source inspection with an automated/LLM-assisted tool, then reproduced and verified it myself.