Skip to content

Fix uouv when handling empty options in ZipArchive::addGlob() #18329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/zip/php_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,13 @@ typedef struct {
#endif
} zip_options;

/* Expects opts to be zero-initialized. */
static int php_zip_parse_options(HashTable *options, zip_options *opts)
/* {{{ */
{
zval *option;

/* default values */
memset(opts, 0, sizeof(zip_options));
opts->flags = ZIP_FL_OVERWRITE;
opts->comp_method = -1; /* -1 to not change default */
#ifdef HAVE_ENCRYPTION
Expand Down Expand Up @@ -1732,7 +1732,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
size_t path_len = 1;
zend_long glob_flags = 0;
HashTable *options = NULL;
zip_options opts;
zip_options opts = {0};
int found;
zend_string *pattern;

Expand Down
22 changes: 22 additions & 0 deletions ext/zip/tests/addGlob_empty_options.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
addGlob with empty options
--EXTENSIONS--
zip
--FILE--
<?php

touch($file = __DIR__ . '/addglob_empty_options.zip');

$zip = new ZipArchive();
$zip->open($file, ZipArchive::CREATE | ZipArchive::OVERWRITE);
$zip->addGlob(__FILE__, 0, []);
var_dump($zip->statIndex(0)['name'] === __FILE__);
$zip->close();

?>
--CLEAN--
<?php
@unlink(__DIR__ . '/addglob_empty_options.zip');
?>
--EXPECT--
bool(true)
Loading