Skip to content

ext/zip: use ZIP_RDONLY when calling zip_open() in zip_stream.c - #23976

Merged
DanielEScherzer merged 2 commits into
php:PHP-8.6from
DanielEScherzer:zip-read-only
Oct 23, 2026
Merged

DanielEScherzer merged 2 commits into
php:PHP-8.6from
DanielEScherzer:zip-read-only

Conversation

@DanielEScherzer

Copy link
Copy Markdown
Member

The code paths that call zip_open() are used for stats and reading, not writing. Previously ZIP_CREATE would create an in-memory zip archive, and if it were written to, would persist it to disk when closed, but since the archive was never written to, this functionality was unneeded. Use the ZIP_RDONLY flag to make it clearer that the zip archive is not being written to.

@LamentXU123

Copy link
Copy Markdown
Member

The Windows CI seems related.

@LamentXU123 LamentXU123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting fix.

Comment thread ext/zip/tests/stats_nonzip.phpt

@LamentXU123 LamentXU123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Will do the merge work later I have time to look at this again :)

A follow-up commit will switch the uses of the `ZIP_CREATE` to instead use
`ZIP_RDONLY` when creation is not desired; add tests to confirm that doing so
does not change the actual behavior of the extension.
The code paths that call `zip_open()` are used for stats and reading, not
writing. Previously `ZIP_CREATE` would create an in-memory zip archive, and if
it were written to, would persist it to disk when closed, but since the archive
was never written to, this functionality was unneeded. Use the `ZIP_RDONLY`
flag to make it clearer that the zip archive is not being written to.
@DanielEScherzer
DanielEScherzer merged commit 1ea3508 into php:PHP-8.6 Oct 23, 2026
18 checks passed
@DanielEScherzer
DanielEScherzer deleted the zip-read-only branch October 23, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants