Skip to content

Commit bc16b94

Browse files
ext/zip: use ZIP_RDONLY when calling zip_open() in zip_stream.c
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.
1 parent 9a7ec37 commit bc16b94

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎ext/zip/zip_stream.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{
162162
return -1;
163163
}
164164

165-
za = zip_open(file_dirname, ZIP_CREATE, &err);
165+
za = zip_open(file_dirname, ZIP_RDONLY, &err);
166166
if (za) {
167167
memset(ssb, 0, sizeof(php_stream_statbuf));
168168
if (zip_stat(za, fragment, ZIP_FL_NOCASE, &sb) != 0) {
@@ -332,7 +332,7 @@ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper,
332332
return NULL;
333333
}
334334

335-
za = zip_open(file_dirname, ZIP_CREATE, &err);
335+
za = zip_open(file_dirname, ZIP_RDONLY, &err);
336336
if (za) {
337337
zval *tmpzval;
338338

0 commit comments

Comments
 (0)