summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2020-05-03 11:49:31 +0200
committerMáté Kocsis <kocsismate@woohoolabs.com>2020-05-06 19:15:34 +0200
commitdaa5b26456820a2414ad2fe0c264df44b43d13ff (patch)
tree8ea15abcf3583669d4b293062c4b3d631bd8df42
parent78dda268eb2887709bdcbb7697785e80e231d58f (diff)
downloadphp-git-daa5b26456820a2414ad2fe0c264df44b43d13ff.tar.gz
Fix UNKNOWN default values in ext/zip
-rw-r--r--ext/zip/php_zip.c20
-rw-r--r--ext/zip/php_zip.stub.php12
-rw-r--r--ext/zip/php_zip_arginfo.h14
3 files changed, 23 insertions, 23 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 2d3b3c3107..dc60312285 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -1725,6 +1725,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
php_error_docref(NULL, E_NOTICE, "Empty string as pattern");
RETURN_FALSE;
}
+ if (options && zend_hash_num_elements(Z_ARRVAL_P(options)) > 0 && (php_zip_parse_options(options, &opts) < 0)) {
RETURN_FALSE;
}
@@ -2302,9 +2303,7 @@ static ZIPARCHIVE_METHOD(setEncryptionName)
char *name, *password = NULL;
size_t name_len, password_len;
- ZIP_FROM_OBJECT(intern, self);
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|s",
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|s!",
&name, &name_len, &method, &password, &password_len) == FAILURE) {
RETURN_THROWS();
}
@@ -2337,14 +2336,14 @@ static ZIPARCHIVE_METHOD(setEncryptionIndex)
char *password = NULL;
size_t password_len;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|s",
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|s!",
&index, &method, &password, &password_len) == FAILURE) {
RETURN_THROWS();
}
- if (zip_file_set_encryption(intern, index, (zip_uint16_t)method, password)) {
ZIP_FROM_OBJECT(intern, self);
+
+ if (zip_file_set_encryption(intern, index, (zip_uint16_t)method, password)) {
RETURN_FALSE;
}
RETURN_TRUE;
@@ -2766,6 +2765,7 @@ static ZIPARCHIVE_METHOD(extractTo)
size_t pathto_len;
int ret;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z", &pathto, &pathto_len, &zval_files) == FAILURE) {
RETURN_THROWS();
}
@@ -2776,10 +2776,10 @@ static ZIPARCHIVE_METHOD(extractTo)
}
if (php_stream_stat_path_ex(pathto, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL) < 0) {
- ret = php_stream_mkdir(pathto, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL);
- if (!ret) {
- RETURN_FALSE;
- }
+ ret = php_stream_mkdir(pathto, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL);
+ if (!ret) {
+ RETURN_FALSE;
+ }
}
if (zval_files && Z_TYPE_P(zval_files) != IS_NULL) {
diff --git a/ext/zip/php_zip.stub.php b/ext/zip/php_zip.stub.php
index 101afcbe8e..e7aabe2c6c 100644
--- a/ext/zip/php_zip.stub.php
+++ b/ext/zip/php_zip.stub.php
@@ -64,16 +64,16 @@ class ZipArchive
public function addFromString(string $name, string $content, int $flags = ZipArchive::FL_OVERWRITE) {}
/** @return bool */
- public function addFile(string $filepath, string $entryname = UNKNOWN, int $start = 0, int $length = 0, int $flags = ZipArchive::FL_OVERWRITE) {}
+ public function addFile(string $filepath, string $entryname = "", int $start = 0, int $length = 0, int $flags = ZipArchive::FL_OVERWRITE) {}
/** @return bool */
public function replaceFile(string $filepath, string $index, int $start = 0, int $length = 0, int $flags = 0) {}
/** @return array|false */
- public function addGlob(string $pattern, int $flags = 0, $options = UNKNOWN) {}
+ public function addGlob(string $pattern, int $flags = 0, array $options = []) {}
/** @return array|false */
- public function addPattern(string $pattern, string $path = UNKNOWN, $options = UNKNOWN) {}
+ public function addPattern(string $pattern, string $path = ".", array $options = []) {}
/** @return bool */
public function renameIndex(int $index, string $new_name) {}
@@ -138,7 +138,7 @@ class ZipArchive
public function unchangeName(string $name) {}
/** @return bool */
- public function extractTo(string $pathto, $files = UNKNOWN) {}
+ public function extractTo(string $pathto, $files = null) {}
/** @return string|false */
public function getFromName(string $entryname, int $len = 0, int $flags = 0) {}
@@ -171,10 +171,10 @@ class ZipArchive
#ifdef HAVE_ENCRYPTION
/** @return bool */
- public function setEncryptionName(string $name, int $method, string $password = UNKNOWN) {}
+ public function setEncryptionName(string $name, int $method, ?string $password = null) {}
/** @return bool */
- public function setEncryptionIndex(int $index, int $method, string $password = UNKNOWN) {}
+ public function setEncryptionIndex(int $index, int $method, ?string $password = null) {}
#endif
#ifdef HAVE_PROGRESS_CALLBACK
diff --git a/ext/zip/php_zip_arginfo.h b/ext/zip/php_zip_arginfo.h
index ac392ef517..31d8168518 100644
--- a/ext/zip/php_zip_arginfo.h
+++ b/ext/zip/php_zip_arginfo.h
@@ -68,7 +68,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ZipArchive_addFile, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, filepath, IS_STRING, 0)
- ZEND_ARG_TYPE_INFO(0, entryname, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, entryname, IS_STRING, 0, "\"\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, start, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "ZipArchive::FL_OVERWRITE")
@@ -85,13 +85,13 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ZipArchive_addGlob, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
- ZEND_ARG_INFO(0, options)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ZipArchive_addPattern, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
- ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0)
- ZEND_ARG_INFO(0, options)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, path, IS_STRING, 0, "\".\"")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ZipArchive_renameIndex, 0, 0, 2)
@@ -174,7 +174,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ZipArchive_extractTo, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, pathto, IS_STRING, 0)
- ZEND_ARG_INFO(0, files)
+ ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, files, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ZipArchive_getFromName, 0, 0, 1)
@@ -245,7 +245,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ZipArchive_setEncryptionName, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, method, IS_LONG, 0)
- ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, password, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
#endif
@@ -253,7 +253,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ZipArchive_setEncryptionIndex, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, method, IS_LONG, 0)
- ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, password, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
#endif