Skip to content

Commit ab63945

Browse files
committed
Mark parameter in ext/zip as sensitive
1 parent 2a331ec commit ab63945

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

ext/zip/php_zip.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "ext/standard/php_string.h"
2727
#include "ext/pcre/php_pcre.h"
2828
#include "ext/standard/php_filestat.h"
29+
#include "zend_attributes.h"
2930
#include "zend_interfaces.h"
3031
#include "php_zip.h"
3132
#include "php_zip_arginfo.h"
@@ -3255,6 +3256,8 @@ static PHP_MINIT_FUNCTION(zip)
32553256
le_zip_dir = zend_register_list_destructors_ex(php_zip_free_dir, NULL, le_zip_dir_name, module_number);
32563257
le_zip_entry = zend_register_list_destructors_ex(php_zip_free_entry, NULL, le_zip_entry_name, module_number);
32573258

3259+
register_php_zip_symbols(module_number, zip_class_entry);
3260+
32583261
return SUCCESS;
32593262
}
32603263
/* }}} */

ext/zip/php_zip.stub.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ class ZipArchive implements Countable
8282
/** @tentative-return-type */
8383
public function open(string $filename, int $flags = 0): bool|int {}
8484

85-
/** @tentative-return-type */
85+
/**
86+
* @sensitive-param $password
87+
* @tentative-return-type
88+
*/
8689
public function setPassword(string $password): bool {}
8790

8891
/** @tentative-return-type */
@@ -223,10 +226,16 @@ public function setCompressionName(string $name, int $method, int $compflags = 0
223226
public function setCompressionIndex(int $index, int $method, int $compflags = 0): bool {}
224227

225228
#ifdef HAVE_ENCRYPTION
226-
/** @tentative-return-type */
229+
/**
230+
* @sensitive-param $password
231+
* @tentative-return-type
232+
*/
227233
public function setEncryptionName(string $name, int $method, ?string $password = null): bool {}
228234

229-
/** @tentative-return-type */
235+
/**
236+
* @sensitive-param $password
237+
* @tentative-return-type
238+
*/
230239
public function setEncryptionIndex(int $index, int $method, ?string $password = null): bool {}
231240
#endif
232241

ext/zip/php_zip_arginfo.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: f6542fda12c523584d476d2b733b4ccc0ffffe32 */
2+
* Stub hash: 60d676af29f53bbc0a52c421975546ce2bef3a43 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_zip_open, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
@@ -486,6 +486,17 @@ static const zend_function_entry class_ZipArchive_methods[] = {
486486
ZEND_FE_END
487487
};
488488

489+
static void register_php_zip_symbols(int module_number, zend_class_entry *class_entry_ZipArchive)
490+
{
491+
zend_mark_function_parameter_as_sensitive(&class_entry_ZipArchive->function_table, "setpassword", 0);
492+
#if defined(HAVE_ENCRYPTION)
493+
zend_mark_function_parameter_as_sensitive(&class_entry_ZipArchive->function_table, "setencryptionname", 2);
494+
#endif
495+
#if defined(HAVE_ENCRYPTION)
496+
zend_mark_function_parameter_as_sensitive(&class_entry_ZipArchive->function_table, "setencryptionindex", 2);
497+
#endif
498+
}
499+
489500
static zend_class_entry *register_class_ZipArchive(zend_class_entry *class_entry_Countable)
490501
{
491502
zend_class_entry ce, *class_entry;

0 commit comments

Comments
 (0)