[php-src] PR #19035: Fix stream double free in phar
| From: | nielsdos | Date: | Sat, 05 Jul 2025 00:16:43 +0000 |
| Subject: | [php-src] PR #19035: Fix stream double free in phar | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-32323@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/19035
Author: nielsdos
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).
Replaces GH-18953.
Will squash on merge.