Skip to content

Conversation

@pull
Copy link

@pull pull bot commented Jul 5, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.2)

Can you help keep this open source service alive? 💖 Please sponsor : )

ndossche and others added 6 commits July 5, 2025 21:31
The copy function does two things wrong:
- The error recovery logic is a hack that temporarily moves the fp
  pointer to cfp, even though it's not compressed. The respective error
  recovery it talks about is not present in the code, nor is it
  necessary. This is the direct cause of the double free in the original
  reproducer. Fixing this makes it crash in another location though.
- The link following logic is inconsistent and illogical. It cannot be a
  link at this point.

The root cause, after fixing the above issues, is that the file pointers
are not reset properly for the copy. The file pointer need to be the
original ones to perform the copy from the right source, but after that
they need to be set properly to NULL (because fp_type == PHAR_FP).

Closes GH-19035.

Co-authored-by: Yun Dou <[email protected]>
* PHP-8.3:
  Fix stream double free in phar
* PHP-8.4:
  Fix stream double free in phar
There are two bugfixes here.
The first was a crash that I discovered while working on GH-19035.
The check for when a file pointer was still occupied was wrong, leading
to a UAF. Strangely, zip got this right.

The second issue was that even after fixing the first one, the file
contents were garbage. This is because the file write offset for the
phar stream was wrong.

Closes GH-19038.
* PHP-8.3:
  Fix phar crash and file corruption with SplFileObject
* PHP-8.4:
  Fix phar crash and file corruption with SplFileObject
@pull pull bot locked and limited conversation to collaborators Jul 5, 2025
@pull pull bot added the ⤵️ pull label Jul 5, 2025
@pull pull bot merged commit 5a2a150 into wudi:master Jul 5, 2025
8 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant