summaryrefslogtreecommitdiffstats
path: root/1b52614c06b60ced6caecd8dcaa0911ed3aa72e2.patch
blob: fbd7750a654e5f2765011d69d336fe2680b819de (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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
From 1b52614c06b60ced6caecd8dcaa0911ed3aa72e2 Mon Sep 17 00:00:00 2001
From: bef <bef@users.noreply.github.com>
Date: Thu, 20 Jun 2019 12:40:07 +0200
Subject: [PATCH] Fix snufflepagus_globals linking issues and one mac
 compatibility issue

---
 src/php_snuffleupagus.h     | 1 +
 src/sp_config.c             | 2 --
 src/sp_config_keywords.c    | 2 --
 src/sp_config_utils.c       | 2 --
 src/sp_cookie_encryption.c  | 2 --
 src/sp_crypt.c              | 2 --
 src/sp_disable_xxe.c        | 2 --
 src/sp_disabled_functions.c | 2 --
 src/sp_execute.c            | 2 --
 src/sp_harden_rand.c        | 2 --
 src/sp_network_utils.c      | 4 +---
 src/sp_session.c            | 2 --
 src/sp_sloppy.c             | 2 --
 src/sp_unserialize.c        | 1 -
 src/sp_upload_validation.c  | 2 --
 src/sp_utils.c              | 2 --
 src/sp_wrapper.c            | 2 --
 src/tweetnacl.c             | 2 --
 18 files changed, 2 insertions(+), 34 deletions(-)

diff --git a/src/php_snuffleupagus.h b/src/php_snuffleupagus.h
index c9313f8..43131fe 100644
--- a/src/php_snuffleupagus.h
+++ b/src/php_snuffleupagus.h
@@ -99,6 +99,7 @@ HashTable *sp_internal_functions_hook;
 HashTable *sp_eval_blacklist_functions_hook;
 ZEND_END_MODULE_GLOBALS(snuffleupagus)
 
+ZEND_EXTERN_MODULE_GLOBALS(snuffleupagus)
 #define SNUFFLEUPAGUS_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(snuffleupagus, v)
 
 #if defined(ZTS) && defined(COMPILE_DL_SNUFFLEUPAGUS)
diff --git a/src/sp_config.c b/src/sp_config.c
index 915c8a1..25223f2 100644
--- a/src/sp_config.c
+++ b/src/sp_config.c
@@ -4,8 +4,6 @@
 
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 size_t sp_line_no;
 
 sp_config_tokens const sp_func[] = {
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c
index a13aed2..abb3110 100644
--- a/src/sp_config_keywords.c
+++ b/src/sp_config_keywords.c
@@ -1,7 +1,5 @@
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 static int parse_enable(char *line, bool *restrict retval,
                         bool *restrict simulation) {
   bool enable = false, disable = false;
diff --git a/src/sp_config_utils.c b/src/sp_config_utils.c
index 71c9071..dbe6793 100644
--- a/src/sp_config_utils.c
+++ b/src/sp_config_utils.c
@@ -1,7 +1,5 @@
 #include "php_snuffleupagus.h"
 
-size_t sp_line_no;
-
 int parse_keywords(sp_config_functions *funcs, char *line) {
   int value_len = 0;
   const char *original_line = line;
diff --git a/src/sp_cookie_encryption.c b/src/sp_cookie_encryption.c
index 249de2d..92a056b 100644
--- a/src/sp_cookie_encryption.c
+++ b/src/sp_cookie_encryption.c
@@ -1,7 +1,5 @@
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 static inline const sp_cookie *sp_lookup_cookie_config(const zend_string *key) {
   const sp_list_node *it = SNUFFLEUPAGUS_G(config).config_cookie->cookies;
 
diff --git a/src/sp_crypt.c b/src/sp_crypt.c
index da0e2fe..42c1510 100644
--- a/src/sp_crypt.c
+++ b/src/sp_crypt.c
@@ -1,7 +1,5 @@
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 void generate_key(unsigned char *key) {
   PHP_SHA256_CTX ctx;
   const char *user_agent = getenv("HTTP_USER_AGENT");
diff --git a/src/sp_disable_xxe.c b/src/sp_disable_xxe.c
index df00dbd..53148c8 100644
--- a/src/sp_disable_xxe.c
+++ b/src/sp_disable_xxe.c
@@ -1,7 +1,5 @@
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 PHP_FUNCTION(sp_libxml_disable_entity_loader) { RETURN_TRUE; }
 
 int hook_libxml_disable_entity_loader() {
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c
index 8177ce1..c088f20 100644
--- a/src/sp_disabled_functions.c
+++ b/src/sp_disabled_functions.c
@@ -1,7 +1,5 @@
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 static void should_disable(zend_execute_data* execute_data,
                            const char* complete_function_path,
                            const zend_string* builtin_param,
diff --git a/src/sp_execute.c b/src/sp_execute.c
index b4f2595..4eae874 100644
--- a/src/sp_execute.c
+++ b/src/sp_execute.c
@@ -1,7 +1,5 @@
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 static void (*orig_execute_ex)(zend_execute_data *execute_data) = NULL;
 static void (*orig_zend_execute_internal)(zend_execute_data *execute_data,
                                           zval *return_value) = NULL;
diff --git a/src/sp_harden_rand.c b/src/sp_harden_rand.c
index 7ab798e..43c2a5b 100644
--- a/src/sp_harden_rand.c
+++ b/src/sp_harden_rand.c
@@ -2,8 +2,6 @@
 
 extern ZEND_API zend_class_entry *zend_ce_error;
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 /* This function is needed because `rand` and `mt_rand` parameters
  * are optional, while the ones from `random_int` aren't. */
 static void random_int_wrapper(INTERNAL_FUNCTION_PARAMETERS) {
diff --git a/src/sp_network_utils.c b/src/sp_network_utils.c
index c444c1e..1811d98 100644
--- a/src/sp_network_utils.c
+++ b/src/sp_network_utils.c
@@ -1,7 +1,5 @@
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 static inline bool cidr4_match(const struct in_addr addr,
                                const struct in_addr net, uint8_t bits);
 static inline bool cidr6_match(const struct in6_addr address,
@@ -19,7 +17,7 @@ static inline bool cidr4_match(const struct in_addr addr,
 
 static inline bool cidr6_match(const struct in6_addr address,
                                const struct in6_addr network, uint8_t bits) {
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
   const uint32_t *a = address.__u6_addr.__u6_addr32;
   const uint32_t *n = network.__u6_addr.__u6_addr32;
 #else
diff --git a/src/sp_session.c b/src/sp_session.c
index 596eae9..1064fe6 100644
--- a/src/sp_session.c
+++ b/src/sp_session.c
@@ -1,7 +1,5 @@
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 #if (HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION))
 
 #ifdef ZTS
diff --git a/src/sp_sloppy.c b/src/sp_sloppy.c
index d3678db..5837783 100644
--- a/src/sp_sloppy.c
+++ b/src/sp_sloppy.c
@@ -1,7 +1,5 @@
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 ZEND_API zend_op_array* (*orig_zend_compile_file)(zend_file_handle* file_handle,
                                                   int type) = NULL;
 ZEND_API zend_op_array* (*orig_zend_compile_string)(zval* source_string,
diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c
index 5e21d6a..f265ce6 100644
--- a/src/sp_unserialize.c
+++ b/src/sp_unserialize.c
@@ -1,6 +1,5 @@
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
 
 PHP_FUNCTION(sp_serialize) {
   zif_handler orig_handler;
diff --git a/src/sp_upload_validation.c b/src/sp_upload_validation.c
index fe16a46..ee19df9 100644
--- a/src/sp_upload_validation.c
+++ b/src/sp_upload_validation.c
@@ -1,7 +1,5 @@
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 int (*sp_rfc1867_orig_callback)(unsigned int event, void *event_data,
                                 void **extra);
 int sp_rfc1867_callback(unsigned int event, void *event_data, void **extra);
diff --git a/src/sp_utils.c b/src/sp_utils.c
index 475d552..7641808 100644
--- a/src/sp_utils.c
+++ b/src/sp_utils.c
@@ -1,7 +1,5 @@
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 bool sp_zend_string_equals(const zend_string* s1, const zend_string* s2) {
   // We can't use `zend_string_equals` here because it doesn't work on
   // `const` zend_string.
diff --git a/src/sp_wrapper.c b/src/sp_wrapper.c
index 1618a4f..277f23a 100644
--- a/src/sp_wrapper.c
+++ b/src/sp_wrapper.c
@@ -1,7 +1,5 @@
 #include "php_snuffleupagus.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 static bool wrapper_is_whitelisted(const zend_string *zs) {
   const sp_list_node *list = SNUFFLEUPAGUS_G(config).config_wrapper->whitelist;
 
diff --git a/src/tweetnacl.c b/src/tweetnacl.c
index ad5dae5..9f66546 100644
--- a/src/tweetnacl.c
+++ b/src/tweetnacl.c
@@ -3,8 +3,6 @@ we're using the one from PHP.*/
 #include "php_snuffleupagus.h"
 #include "ext/standard/php_random.h"
 
-ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
-
 void randombytes(unsigned char *x, unsigned long long xlen) {
   assert(SIZE_MAX >= ULLONG_MAX);  // max(size_t) > max(ull) ?
   php_random_bytes(x, xlen, 1);