diff options
| author | Remi Collet <remi@php.net> | 2017-03-02 13:36:40 +0100 |
|---|---|---|
| committer | Remi Collet <remi@php.net> | 2017-03-02 13:36:40 +0100 |
| commit | 402eeb85988be91d90a92eff94635b6e9ef6160e (patch) | |
| tree | daa4427a300d8560f35dd262e8986acead3d3ccf /ext/zip/zip_stream.c | |
| parent | 859a6505d3bdb017f68ea1beedb118e3758ccb6f (diff) | |
| download | php-git-402eeb85988be91d90a92eff94635b6e9ef6160e.tar.gz | |
Zip: add support for encrypted archive
Diffstat (limited to 'ext/zip/zip_stream.c')
| -rw-r--r-- | ext/zip/zip_stream.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c index 2fa828a572..2ed584021d 100644 --- a/ext/zip/zip_stream.c +++ b/ext/zip/zip_stream.c @@ -309,6 +309,14 @@ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, za = zip_open(file_dirname, ZIP_CREATE, &err); if (za) { + zval *tmpzval; + + if (NULL != (tmpzval = php_stream_context_get_option(context, "zip", "password"))) { + if (Z_TYPE_P(tmpzval) != IS_STRING || zip_set_default_password(za, Z_STRVAL_P(tmpzval))) { + php_error_docref(NULL, E_WARNING, "Can't set zip password"); + } + } + zf = zip_fopen(za, fragment, 0); if (zf) { self = emalloc(sizeof(*self)); @@ -348,7 +356,7 @@ static php_stream_wrapper_ops zip_stream_wops = { NULL, /* rename */ NULL, /* mkdir */ NULL, /* rmdir */ - NULL + NULL /* metadata */ }; php_stream_wrapper php_stream_zip_wrapper = { |
