summaryrefslogtreecommitdiffstats
path: root/zip-upstream.patch
blob: 8783350078dddb741d38486ec785394ae51dcfb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
From e8de7d2a4dbe91a80bb23642eaf07342503f691a Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 12 Jul 2022 14:37:51 +0200
Subject: [PATCH 1/3] Support the actual `#[\SensitiveParameter]` attribute in
 stubs (for upcoming 8.2.0beta1)

---
 php81/php_zip.c         |  3 ---
 php81/php_zip.stub.php  |  9 +++------
 php81/php_zip_arginfo.h | 17 +++++++++++++----
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/php81/php_zip.c b/php81/php_zip.c
index 0de9189..29a067d 100644
--- a/php81/php_zip.c
+++ b/php81/php_zip.c
@@ -29,9 +29,6 @@
 #include "zend_attributes.h"
 #include "zend_interfaces.h"
 #include "php_zip.h"
-#if PHP_VERSION_ID < 80200
-#define zend_mark_function_parameter_as_sensitive(a,b,c)
-#endif
 #include "php_zip_arginfo.h"
 
 #ifdef HAVE_GLOB
diff --git a/php81/php_zip.stub.php b/php81/php_zip.stub.php
index a0866e1..aa7d783 100644
--- a/php81/php_zip.stub.php
+++ b/php81/php_zip.stub.php
@@ -83,10 +83,9 @@ class ZipArchive implements Countable
     public function open(string $filename, int $flags = 0): bool|int {}
 
     /**
-     * @sensitive-param $password
      * @tentative-return-type
      */
-    public function setPassword(string $password): bool {}
+    public function setPassword(#[\SensitiveParameter] string $password): bool {}
 
     /** @tentative-return-type */
     public function close(): bool {}
@@ -227,16 +226,14 @@ class ZipArchive implements Countable
 
 #ifdef HAVE_ENCRYPTION
     /**
-     * @sensitive-param $password
      * @tentative-return-type
      */
-    public function setEncryptionName(string $name, int $method, ?string $password = null): bool {}
+    public function setEncryptionName(string $name, int $method, #[\SensitiveParameter] ?string $password = null): bool {}
 
     /**
-     * @sensitive-param $password
      * @tentative-return-type
      */
-    public function setEncryptionIndex(int $index, int $method, ?string $password = null): bool {}
+    public function setEncryptionIndex(int $index, int $method, #[\SensitiveParameter] ?string $password = null): bool {}
 #endif
 
 #ifdef HAVE_PROGRESS_CALLBACK
diff --git a/php81/php_zip_arginfo.h b/php81/php_zip_arginfo.h
index 6f00051..a3ec214 100644
--- a/php81/php_zip_arginfo.h
+++ b/php81/php_zip_arginfo.h
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: f8ec36ea62bfbdb74cfa6472227e08d9282413a2 */
+ * Stub hash: 9c44d8bcf6b97804d539a9dd566d5faca60074ba */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_zip_open, 0, 0, 1)
 	ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
@@ -530,12 +530,21 @@ static zend_class_entry *register_class_ZipArchive(zend_class_entry *class_entry
 	zend_declare_typed_property(class_entry, property_comment_name, &property_comment_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING));
 	zend_string_release(property_comment_name);
 
-	zend_mark_function_parameter_as_sensitive(&class_entry->function_table, "setpassword", 0);
+
+	zend_string *attribute_name_SensitiveParameter_ZipArchive_setPassword_arg0 = zend_string_init("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1);
+	zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setpassword", sizeof("setpassword") - 1), 0, attribute_name_SensitiveParameter_ZipArchive_setPassword_arg0, 0);
+	zend_string_release(attribute_name_SensitiveParameter_ZipArchive_setPassword_arg0);
 #if defined(HAVE_ENCRYPTION)
-	zend_mark_function_parameter_as_sensitive(&class_entry->function_table, "setencryptionname", 2);
+
+	zend_string *attribute_name_SensitiveParameter_ZipArchive_setEncryptionName_arg2 = zend_string_init("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1);
+	zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionname", sizeof("setencryptionname") - 1), 2, attribute_name_SensitiveParameter_ZipArchive_setEncryptionName_arg2, 0);
+	zend_string_release(attribute_name_SensitiveParameter_ZipArchive_setEncryptionName_arg2);
 #endif
 #if defined(HAVE_ENCRYPTION)
-	zend_mark_function_parameter_as_sensitive(&class_entry->function_table, "setencryptionindex", 2);
+
+	zend_string *attribute_name_SensitiveParameter_ZipArchive_setEncryptionIndex_arg2 = zend_string_init("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1);
+	zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionindex", sizeof("setencryptionindex") - 1), 2, attribute_name_SensitiveParameter_ZipArchive_setEncryptionIndex_arg2, 0);
+	zend_string_release(attribute_name_SensitiveParameter_ZipArchive_setEncryptionIndex_arg2);
 #endif
 
 	return class_entry;
-- 
2.35.3

From f94c6772a49e5d9860b0abffc32a56a0a33a6216 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Mon, 18 Jul 2022 12:32:56 +0200
Subject: [PATCH 2/3] add SensitiveParameter as known string and use it in
 arginfo

---
 php81/php_zip_arginfo.h | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/php81/php_zip_arginfo.h b/php81/php_zip_arginfo.h
index a3ec214..8fb3bb9 100644
--- a/php81/php_zip_arginfo.h
+++ b/php81/php_zip_arginfo.h
@@ -531,20 +531,14 @@ static zend_class_entry *register_class_ZipArchive(zend_class_entry *class_entry
 	zend_string_release(property_comment_name);
 
 
-	zend_string *attribute_name_SensitiveParameter_ZipArchive_setPassword_arg0 = zend_string_init("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1);
-	zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setpassword", sizeof("setpassword") - 1), 0, attribute_name_SensitiveParameter_ZipArchive_setPassword_arg0, 0);
-	zend_string_release(attribute_name_SensitiveParameter_ZipArchive_setPassword_arg0);
+	zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setpassword", sizeof("setpassword") - 1), 0, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0);
 #if defined(HAVE_ENCRYPTION)
 
-	zend_string *attribute_name_SensitiveParameter_ZipArchive_setEncryptionName_arg2 = zend_string_init("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1);
-	zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionname", sizeof("setencryptionname") - 1), 2, attribute_name_SensitiveParameter_ZipArchive_setEncryptionName_arg2, 0);
-	zend_string_release(attribute_name_SensitiveParameter_ZipArchive_setEncryptionName_arg2);
+	zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionname", sizeof("setencryptionname") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0);
 #endif
 #if defined(HAVE_ENCRYPTION)
 
-	zend_string *attribute_name_SensitiveParameter_ZipArchive_setEncryptionIndex_arg2 = zend_string_init("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1);
-	zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionindex", sizeof("setencryptionindex") - 1), 2, attribute_name_SensitiveParameter_ZipArchive_setEncryptionIndex_arg2, 0);
-	zend_string_release(attribute_name_SensitiveParameter_ZipArchive_setEncryptionIndex_arg2);
+	zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionindex", sizeof("setencryptionindex") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0);
 #endif
 
 	return class_entry;
-- 
2.35.3

From cbaf00ce8f6f5165399d81ff345cc6cc6f8a75d7 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Wed, 20 Jul 2022 07:29:36 +0200
Subject: [PATCH 3/3] compat for 8.1

---
 php81/php_zip.stub.php  | 5 ++++-
 php81/php_zip_arginfo.h | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/php81/php_zip.stub.php b/php81/php_zip.stub.php
index aa7d783..bab802c 100644
--- a/php81/php_zip.stub.php
+++ b/php81/php_zip.stub.php
@@ -1,6 +1,9 @@
 <?php
 
-/** @generate-class-entries */
+/**
+ * @generate-class-entries
+ * @generate-legacy-arginfo 80100
+ */
 
 /**
  * @return resource|int|false
diff --git a/php81/php_zip_arginfo.h b/php81/php_zip_arginfo.h
index 8fb3bb9..da387d6 100644
--- a/php81/php_zip_arginfo.h
+++ b/php81/php_zip_arginfo.h
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 9c44d8bcf6b97804d539a9dd566d5faca60074ba */
+ * Stub hash: e077100efd41822053ca2e1ee6c62c764714e325 */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_zip_open, 0, 0, 1)
 	ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
@@ -529,6 +529,7 @@ static zend_class_entry *register_class_ZipArchive(zend_class_entry *class_entry
 	zend_string *property_comment_name = zend_string_init("comment", sizeof("comment") - 1, 1);
 	zend_declare_typed_property(class_entry, property_comment_name, &property_comment_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING));
 	zend_string_release(property_comment_name);
+#if (PHP_VERSION_ID >= 80200)
 
 
 	zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setpassword", sizeof("setpassword") - 1), 0, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0);
@@ -539,6 +540,7 @@ static zend_class_entry *register_class_ZipArchive(zend_class_entry *class_entry
 #if defined(HAVE_ENCRYPTION)
 
 	zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionindex", sizeof("setencryptionindex") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0);
+#endif
 #endif
 
 	return class_entry;
-- 
2.35.3