Magellan Linux

Annotation of /trunk/php5/patches/php5-5.2.6-suhosin-0.9.6.2.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 671 - (hide annotations) (download)
Sun Aug 17 17:36:49 2008 UTC (15 years, 10 months ago) by niro
File size: 93519 byte(s)
-re-diffed against 5.2.6

1 niro 671 diff -Nura php-5.2.6/TSRM/TSRM.h suhosin-patch-5.2.6/TSRM/TSRM.h
2     --- php-5.2.6/TSRM/TSRM.h 2007-12-31 08:20:02.000000000 +0100
3     +++ suhosin-patch-5.2.6/TSRM/TSRM.h 2008-05-01 11:54:41.000000000 +0200
4     @@ -38,6 +38,13 @@
5     typedef unsigned long tsrm_uintptr_t;
6     #endif
7    
8     +#if SUHOSIN_PATCH
9     +# if HAVE_REALPATH
10     +# undef realpath
11     +# define realpath php_realpath
12     +# endif
13     +#endif
14     +
15     /* Only compile multi-threading functions if we're in ZTS mode */
16     #ifdef ZTS
17    
18     @@ -93,6 +100,7 @@
19    
20     #define THREAD_HASH_OF(thr,ts) (unsigned long)thr%(unsigned long)ts
21    
22     +
23     #ifdef __cplusplus
24     extern "C" {
25     #endif
26     diff -Nura php-5.2.6/TSRM/tsrm_virtual_cwd.c suhosin-patch-5.2.6/TSRM/tsrm_virtual_cwd.c
27     --- php-5.2.6/TSRM/tsrm_virtual_cwd.c 2007-12-31 08:20:02.000000000 +0100
28     +++ suhosin-patch-5.2.6/TSRM/tsrm_virtual_cwd.c 2008-05-01 11:54:41.000000000 +0200
29     @@ -273,6 +273,178 @@
30     }
31     /* }}} */
32    
33     +#if SUHOSIN_PATCH
34     +CWD_API char *php_realpath(const char *path, char *resolved)
35     +{
36     + struct stat sb;
37     + char *p, *q, *s;
38     + size_t left_len, resolved_len;
39     + unsigned symlinks;
40     + int serrno, slen;
41     + int is_dir = 1;
42     + char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX];
43     +
44     + serrno = errno;
45     + symlinks = 0;
46     + if (path[0] == '/') {
47     + resolved[0] = '/';
48     + resolved[1] = '\0';
49     + if (path[1] == '\0')
50     + return (resolved);
51     + resolved_len = 1;
52     + left_len = strlcpy(left, path + 1, sizeof(left));
53     + } else {
54     + if (getcwd(resolved, PATH_MAX) == NULL) {
55     + strlcpy(resolved, ".", PATH_MAX);
56     + return (NULL);
57     + }
58     + resolved_len = strlen(resolved);
59     + left_len = strlcpy(left, path, sizeof(left));
60     + }
61     + if (left_len >= sizeof(left) || resolved_len >= PATH_MAX) {
62     + errno = ENAMETOOLONG;
63     + return (NULL);
64     + }
65     +
66     + /*
67     + * Iterate over path components in `left'.
68     + */
69     + while (left_len != 0) {
70     + /*
71     + * Extract the next path component and adjust `left'
72     + * and its length.
73     + */
74     + p = strchr(left, '/');
75     + s = p ? p : left + left_len;
76     + if (s - left >= sizeof(next_token)) {
77     + errno = ENAMETOOLONG;
78     + return (NULL);
79     + }
80     + memcpy(next_token, left, s - left);
81     + next_token[s - left] = '\0';
82     + left_len -= s - left;
83     + if (p != NULL)
84     + memmove(left, s + 1, left_len + 1);
85     + if (resolved[resolved_len - 1] != '/') {
86     + if (resolved_len + 1 >= PATH_MAX) {
87     + errno = ENAMETOOLONG;
88     + return (NULL);
89     + }
90     + resolved[resolved_len++] = '/';
91     + resolved[resolved_len] = '\0';
92     + }
93     + if (next_token[0] == '\0')
94     + continue;
95     + else if (strcmp(next_token, ".") == 0)
96     + continue;
97     + else if (strcmp(next_token, "..") == 0) {
98     + /*
99     + * Strip the last path component except when we have
100     + * single "/"
101     + */
102     + if (!is_dir) {
103     + errno = ENOENT;
104     + return (NULL);
105     + }
106     + if (resolved_len > 1) {
107     + resolved[resolved_len - 1] = '\0';
108     + q = strrchr(resolved, '/');
109     + *q = '\0';
110     + resolved_len = q - resolved;
111     + }
112     + continue;
113     + }
114     +
115     + /*
116     + * Append the next path component and lstat() it. If
117     + * lstat() fails we still can return successfully if
118     + * there are no more path components left.
119     + */
120     + resolved_len = strlcat(resolved, next_token, PATH_MAX);
121     + if (resolved_len >= PATH_MAX) {
122     + errno = ENAMETOOLONG;
123     + return (NULL);
124     + }
125     + if (lstat(resolved, &sb) != 0) {
126     + if (errno == ENOENT) {
127     + if (p == NULL) {
128     + errno = serrno;
129     + return NULL;
130     + return (resolved);
131     + } /*else if (strstr(left, "/.") == NULL && strstr(left, "./") == NULL) {
132     + resolved_len = strlcat(resolved, "/", PATH_MAX);
133     + resolved_len = strlcat(resolved, left, PATH_MAX);
134     + if (resolved_len >= PATH_MAX) {
135     + errno = ENAMETOOLONG;
136     + return (NULL);
137     + }
138     + errno = serrno;
139     + return (resolved);
140     + } */
141     + }
142     + return (NULL);
143     + }
144     + if (S_ISLNK(sb.st_mode)) {
145     + if (symlinks++ > MAXSYMLINKS) {
146     + errno = ELOOP;
147     + return (NULL);
148     + }
149     + slen = readlink(resolved, symlink, sizeof(symlink) - 1);
150     + if (slen < 0)
151     + return (NULL);
152     + symlink[slen] = '\0';
153     + if (symlink[0] == '/') {
154     + resolved[1] = 0;
155     + resolved_len = 1;
156     + } else if (resolved_len > 1) {
157     + /* Strip the last path component. */
158     + resolved[resolved_len - 1] = '\0';
159     + q = strrchr(resolved, '/');
160     + *q = '\0';
161     + resolved_len = q - resolved;
162     + }
163     +
164     + /*
165     + * If there are any path components left, then
166     + * append them to symlink. The result is placed
167     + * in `left'.
168     + */
169     + if (p != NULL) {
170     + if (symlink[slen - 1] != '/') {
171     + if (slen + 1 >= sizeof(symlink)) {
172     + errno = ENAMETOOLONG;
173     + return (NULL);
174     + }
175     + symlink[slen] = '/';
176     + symlink[slen + 1] = 0;
177     + }
178     + left_len = strlcat(symlink, left, sizeof(left));
179     + if (left_len >= sizeof(left)) {
180     + errno = ENAMETOOLONG;
181     + return (NULL);
182     + }
183     + }
184     + left_len = strlcpy(left, symlink, sizeof(left));
185     + } else {
186     + if (S_ISDIR(sb.st_mode)) {
187     + is_dir = 1;
188     + } else {
189     + is_dir = 0;
190     + }
191     + }
192     + }
193     +
194     + /*
195     + * Remove trailing slash except when the resolved pathname
196     + * is a single "/".
197     + */
198     + if (resolved_len > 1 && resolved[resolved_len - 1] == '/')
199     + resolved[resolved_len - 1] = '\0';
200     + return (resolved);
201     +}
202     +#endif
203     +
204     +
205     CWD_API void virtual_cwd_startup(void) /* {{{ */
206     {
207     char cwd[MAXPATHLEN];
208     diff -Nura php-5.2.6/TSRM/tsrm_virtual_cwd.h suhosin-patch-5.2.6/TSRM/tsrm_virtual_cwd.h
209     --- php-5.2.6/TSRM/tsrm_virtual_cwd.h 2007-12-31 08:20:02.000000000 +0100
210     +++ suhosin-patch-5.2.6/TSRM/tsrm_virtual_cwd.h 2008-05-01 11:54:41.000000000 +0200
211     @@ -139,6 +139,22 @@
212    
213     typedef int (*verify_path_func)(const cwd_state *);
214    
215     +#ifndef HAVE_STRLCPY
216     +CWD_API size_t php_strlcpy(char *dst, const char *src, size_t siz);
217     +#undef strlcpy
218     +#define strlcpy php_strlcpy
219     +#endif
220     +
221     +#ifndef HAVE_STRLCAT
222     +CWD_API size_t php_strlcat(char *dst, const char *src, size_t siz);
223     +#undef strlcat
224     +#define strlcat php_strlcat
225     +#endif
226     +
227     +
228     +#if SUHOSIN_PATCH
229     +CWD_API char *php_realpath(const char *path, char *resolved);
230     +#endif
231     CWD_API void virtual_cwd_startup(void);
232     CWD_API void virtual_cwd_shutdown(void);
233     CWD_API char *virtual_getcwd_ex(size_t *length TSRMLS_DC);
234     diff -Nura php-5.2.6/Zend/Makefile.am suhosin-patch-5.2.6/Zend/Makefile.am
235     --- php-5.2.6/Zend/Makefile.am 2006-12-05 09:07:57.000000000 +0100
236     +++ suhosin-patch-5.2.6/Zend/Makefile.am 2008-05-01 11:54:41.000000000 +0200
237     @@ -17,7 +17,7 @@
238     zend_objects_API.c zend_ts_hash.c zend_stream.c \
239     zend_default_classes.c \
240     zend_iterators.c zend_interfaces.c zend_exceptions.c \
241     - zend_strtod.c zend_multibyte.c
242     + zend_strtod.c zend_multibyte.c zend_canary.c
243    
244     libZend_la_LDFLAGS =
245     libZend_la_LIBADD = @ZEND_EXTRA_LIBS@
246     diff -Nura php-5.2.6/Zend/Zend.dsp suhosin-patch-5.2.6/Zend/Zend.dsp
247     --- php-5.2.6/Zend/Zend.dsp 2006-12-05 09:07:57.000000000 +0100
248     +++ suhosin-patch-5.2.6/Zend/Zend.dsp 2008-05-01 11:57:11.000000000 +0200
249     @@ -239,6 +239,10 @@
250     # End Source File
251     # Begin Source File
252    
253     +SOURCE=.\zend_canary.c
254     +# End Source File
255     +# Begin Source File
256     +
257     SOURCE=.\zend_ts_hash.c
258     # End Source File
259     # Begin Source File
260     diff -Nura php-5.2.6/Zend/ZendTS.dsp suhosin-patch-5.2.6/Zend/ZendTS.dsp
261     --- php-5.2.6/Zend/ZendTS.dsp 2006-12-05 09:07:57.000000000 +0100
262     +++ suhosin-patch-5.2.6/Zend/ZendTS.dsp 2008-05-01 11:56:34.000000000 +0200
263     @@ -273,6 +273,10 @@
264     # End Source File
265     # Begin Source File
266    
267     +SOURCE=.\zend_canary.c
268     +# End Source File
269     +# Begin Source File
270     +
271     SOURCE=.\zend_ts_hash.c
272     # End Source File
273     # Begin Source File
274     diff -Nura php-5.2.6/Zend/zend.c suhosin-patch-5.2.6/Zend/zend.c
275     --- php-5.2.6/Zend/zend.c 2007-12-31 08:20:02.000000000 +0100
276     +++ suhosin-patch-5.2.6/Zend/zend.c 2008-05-01 11:54:41.000000000 +0200
277     @@ -57,7 +57,9 @@
278     ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
279     int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
280     ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
281     -
282     +#if SUHOSIN_PATCH
283     +ZEND_API void (*zend_suhosin_log)(int loglevel, char *fmt, ...);
284     +#endif
285     void (*zend_on_timeout)(int seconds TSRMLS_DC);
286    
287     static void (*zend_message_dispatcher_p)(long message, void *data);
288     @@ -74,9 +76,88 @@
289     return SUCCESS;
290     }
291    
292     +#if SUHOSIN_PATCH
293     +static ZEND_INI_MH(OnUpdateSuhosin_log_syslog)
294     +{
295     + if (!new_value) {
296     + SPG(log_syslog) = S_ALL & ~S_SQL | S_MEMORY;
297     + } else {
298     + SPG(log_syslog) = atoi(new_value) | S_MEMORY;
299     + }
300     + return SUCCESS;
301     +}
302     +static ZEND_INI_MH(OnUpdateSuhosin_log_syslog_facility)
303     +{
304     + if (!new_value) {
305     + SPG(log_syslog_facility) = LOG_USER;
306     + } else {
307     + SPG(log_syslog_facility) = atoi(new_value);
308     + }
309     + return SUCCESS;
310     +}
311     +static ZEND_INI_MH(OnUpdateSuhosin_log_syslog_priority)
312     +{
313     + if (!new_value) {
314     + SPG(log_syslog_priority) = LOG_ALERT;
315     + } else {
316     + SPG(log_syslog_priority) = atoi(new_value);
317     + }
318     + return SUCCESS;
319     +}
320     +static ZEND_INI_MH(OnUpdateSuhosin_log_sapi)
321     +{
322     + if (!new_value) {
323     + SPG(log_sapi) = S_ALL & ~S_SQL;
324     + } else {
325     + SPG(log_sapi) = atoi(new_value);
326     + }
327     + return SUCCESS;
328     +}
329     +static ZEND_INI_MH(OnUpdateSuhosin_log_script)
330     +{
331     + if (!new_value) {
332     + SPG(log_script) = S_ALL & ~S_MEMORY;
333     + } else {
334     + SPG(log_script) = atoi(new_value) & (~S_MEMORY) & (~S_INTERNAL);
335     + }
336     + return SUCCESS;
337     +}
338     +static ZEND_INI_MH(OnUpdateSuhosin_log_scriptname)
339     +{
340     + if (SPG(log_scriptname)) {
341     + pefree(SPG(log_scriptname),1);
342     + }
343     + SPG(log_scriptname) = NULL;
344     + if (new_value) {
345     + SPG(log_scriptname) = pestrdup(new_value,1);
346     + }
347     + return SUCCESS;
348     +}
349     +static ZEND_INI_MH(OnUpdateSuhosin_log_phpscript)
350     +{
351     + if (!new_value) {
352     + SPG(log_phpscript) = S_ALL & ~S_MEMORY;
353     + } else {
354     + SPG(log_phpscript) = atoi(new_value) & (~S_MEMORY) & (~S_INTERNAL);
355     + }
356     + return SUCCESS;
357     +}
358     +#endif
359    
360     ZEND_INI_BEGIN()
361     ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting)
362     +#if SUHOSIN_PATCH
363     + ZEND_INI_ENTRY("suhosin.log.syslog", NULL, ZEND_INI_PERDIR|ZEND_INI_SYSTEM, OnUpdateSuhosin_log_syslog)
364     + ZEND_INI_ENTRY("suhosin.log.syslog.facility", NULL, ZEND_INI_PERDIR|ZEND_INI_SYSTEM, OnUpdateSuhosin_log_syslog_facility)
365     + ZEND_INI_ENTRY("suhosin.log.syslog.priority", NULL, ZEND_INI_PERDIR|ZEND_INI_SYSTEM, OnUpdateSuhosin_log_syslog_priority)
366     + ZEND_INI_ENTRY("suhosin.log.sapi", NULL, ZEND_INI_PERDIR|ZEND_INI_SYSTEM, OnUpdateSuhosin_log_sapi)
367     + ZEND_INI_ENTRY("suhosin.log.script", NULL, ZEND_INI_PERDIR|ZEND_INI_SYSTEM, OnUpdateSuhosin_log_script)
368     + ZEND_INI_ENTRY("suhosin.log.script.name", NULL, ZEND_INI_SYSTEM, OnUpdateSuhosin_log_scriptname)
369     + STD_ZEND_INI_BOOLEAN("suhosin.log.use-x-forwarded-for", "0", ZEND_INI_PERDIR|ZEND_INI_SYSTEM, OnUpdateBool, log_use_x_forwarded_for, suhosin_patch_globals_struct, suhosin_patch_globals)
370     + ZEND_INI_ENTRY("suhosin.log.phpscript", "0", ZEND_INI_PERDIR|ZEND_INI_SYSTEM, OnUpdateSuhosin_log_phpscript)
371     + STD_ZEND_INI_ENTRY("suhosin.log.phpscript.name", NULL, ZEND_INI_PERDIR|ZEND_INI_SYSTEM, OnUpdateString, log_phpscriptname, suhosin_patch_globals_struct, suhosin_patch_globals)
372     + STD_ZEND_INI_BOOLEAN("suhosin.log.phpscript.is_safe", "0", ZEND_INI_SYSTEM, OnUpdateBool, log_phpscript_is_safe, suhosin_patch_globals_struct, suhosin_patch_globals)
373     +#endif
374     STD_ZEND_INI_BOOLEAN("zend.ze1_compatibility_mode", "0", ZEND_INI_ALL, OnUpdateBool, ze1_compatibility_mode, zend_executor_globals, executor_globals)
375     #ifdef ZEND_MULTIBYTE
376     STD_ZEND_INI_BOOLEAN("detect_unicode", "1", ZEND_INI_ALL, OnUpdateBool, detect_unicode, zend_compiler_globals, compiler_globals)
377     diff -Nura php-5.2.6/Zend/zend.h suhosin-patch-5.2.6/Zend/zend.h
378     --- php-5.2.6/Zend/zend.h 2008-02-15 08:44:45.000000000 +0100
379     +++ suhosin-patch-5.2.6/Zend/zend.h 2008-05-01 11:54:41.000000000 +0200
380     @@ -532,6 +532,9 @@
381     extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
382     extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
383     extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
384     +#if SUHOSIN_PATCH
385     +extern ZEND_API void (*zend_suhosin_log)(int loglevel, char *fmt, ...);
386     +#endif
387    
388    
389     ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
390     @@ -663,6 +666,13 @@
391     #include "zend_operators.h"
392     #include "zend_variables.h"
393    
394     +#if SUHOSIN_PATCH
395     +#include "suhosin_globals.h"
396     +#include "php_syslog.h"
397     +
398     +ZEND_API size_t zend_canary();
399     +#endif
400     +
401     #endif /* ZEND_H */
402    
403     /*
404     diff -Nura php-5.2.6/Zend/zend_alloc.c suhosin-patch-5.2.6/Zend/zend_alloc.c
405     --- php-5.2.6/Zend/zend_alloc.c 2008-02-14 15:46:48.000000000 +0100
406     +++ suhosin-patch-5.2.6/Zend/zend_alloc.c 2008-05-01 11:54:41.000000000 +0200
407     @@ -311,13 +311,26 @@
408     #define MEM_BLOCK_GUARD 0x2A8FCC84
409     #define MEM_BLOCK_LEAK 0x6C5E8F2D
410    
411     +#if SUHOSIN_PATCH
412     +# define CANARY_SIZE sizeof(size_t)
413     +#else
414     +# define CANARY_SIZE 0
415     +#endif
416     +
417     /* mm block type */
418     typedef struct _zend_mm_block_info {
419     #if ZEND_MM_COOKIES
420     size_t _cookie;
421     #endif
422     - size_t _size;
423     - size_t _prev;
424     +#if SUHOSIN_PATCH
425     + size_t canary_1;
426     +#endif
427     + size_t _size;
428     + size_t _prev;
429     +#if SUHOSIN_PATCH
430     + size_t size;
431     + size_t canary_2;
432     +#endif
433     } zend_mm_block_info;
434    
435     #if ZEND_DEBUG
436     @@ -423,6 +436,9 @@
437     int miss;
438     } cache_stat[ZEND_MM_NUM_BUCKETS+1];
439     #endif
440     +#if SUHOSIN_PATCH
441     + size_t canary_1,canary_2,canary_3;
442     +#endif
443     };
444    
445     #define ZEND_MM_SMALL_FREE_BUCKET(heap, index) \
446     @@ -512,15 +528,15 @@
447     #define ZEND_MM_ALIGNED_SIZE(size) ((size + ZEND_MM_ALIGNMENT - 1) & ZEND_MM_ALIGNMENT_MASK)
448     #define ZEND_MM_ALIGNED_HEADER_SIZE ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_block))
449     #define ZEND_MM_ALIGNED_FREE_HEADER_SIZE ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_small_free_block))
450     -#define ZEND_MM_MIN_ALLOC_BLOCK_SIZE ZEND_MM_ALIGNED_SIZE(ZEND_MM_ALIGNED_HEADER_SIZE + END_MAGIC_SIZE)
451     +#define ZEND_MM_MIN_ALLOC_BLOCK_SIZE ZEND_MM_ALIGNED_SIZE(ZEND_MM_ALIGNED_HEADER_SIZE + END_MAGIC_SIZE + CANARY_SIZE)
452     #define ZEND_MM_ALIGNED_MIN_HEADER_SIZE (ZEND_MM_MIN_ALLOC_BLOCK_SIZE>ZEND_MM_ALIGNED_FREE_HEADER_SIZE?ZEND_MM_MIN_ALLOC_BLOCK_SIZE:ZEND_MM_ALIGNED_FREE_HEADER_SIZE)
453     #define ZEND_MM_ALIGNED_SEGMENT_SIZE ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_segment))
454    
455     -#define ZEND_MM_MIN_SIZE ((ZEND_MM_ALIGNED_MIN_HEADER_SIZE>(ZEND_MM_ALIGNED_HEADER_SIZE+END_MAGIC_SIZE))?(ZEND_MM_ALIGNED_MIN_HEADER_SIZE-(ZEND_MM_ALIGNED_HEADER_SIZE+END_MAGIC_SIZE)):0)
456     +#define ZEND_MM_MIN_SIZE ((ZEND_MM_ALIGNED_MIN_HEADER_SIZE>(ZEND_MM_ALIGNED_HEADER_SIZE+END_MAGIC_SIZE+CANARY_SIZE))?(ZEND_MM_ALIGNED_MIN_HEADER_SIZE-(ZEND_MM_ALIGNED_HEADER_SIZE+END_MAGIC_SIZE+CANARY_SIZE)):0)
457    
458     #define ZEND_MM_MAX_SMALL_SIZE ((ZEND_MM_NUM_BUCKETS<<ZEND_MM_ALIGNMENT_LOG2)+ZEND_MM_ALIGNED_MIN_HEADER_SIZE)
459    
460     -#define ZEND_MM_TRUE_SIZE(size) ((size<ZEND_MM_MIN_SIZE)?(ZEND_MM_ALIGNED_MIN_HEADER_SIZE):(ZEND_MM_ALIGNED_SIZE(size+ZEND_MM_ALIGNED_HEADER_SIZE+END_MAGIC_SIZE)))
461     +#define ZEND_MM_TRUE_SIZE(size) ((size<ZEND_MM_MIN_SIZE)?(ZEND_MM_ALIGNED_MIN_HEADER_SIZE):(ZEND_MM_ALIGNED_SIZE(size+ZEND_MM_ALIGNED_HEADER_SIZE+END_MAGIC_SIZE+CANARY_SIZE)))
462    
463     #define ZEND_MM_BUCKET_INDEX(true_size) ((true_size>>ZEND_MM_ALIGNMENT_LOG2)-(ZEND_MM_ALIGNED_MIN_HEADER_SIZE>>ZEND_MM_ALIGNMENT_LOG2))
464    
465     @@ -582,6 +598,48 @@
466    
467     #endif
468    
469     +#if SUHOSIN_PATCH
470     +
471     +# define SUHOSIN_MM_CHECK_CANARIES(block, MFUNCTION) do { \
472     + size_t *p = SUHOSIN_MM_END_CANARY_PTR(block), check; \
473     + if (((block)->info.canary_1 != heap->canary_1) || ((block)->info.canary_2 != heap->canary_2)) { \
474     + canary_mismatch: \
475     + zend_suhosin_log(S_MEMORY, "canary mismatch on " MFUNCTION " - heap overflow detected"); \
476     + exit(1); \
477     + } \
478     + memcpy(&check, p, CANARY_SIZE); \
479     + if (check != heap->canary_3) { \
480     + zend_suhosin_log(S_MEMORY, "canary mismatch on " MFUNCTION " - heap overflow detected"); \
481     + exit(1); \
482     + goto canary_mismatch; \
483     + } \
484     + } while (0)
485     +
486     +# define SUHOSIN_MM_SET_CANARIES(block) do { \
487     + (block)->info.canary_1 = heap->canary_1; \
488     + (block)->info.canary_2 = heap->canary_2; \
489     + } while (0)
490     +
491     +# define SUHOSIN_MM_END_CANARY_PTR(block) \
492     + (size_t*)(((char*)(ZEND_MM_DATA_OF(block))) + ((zend_mm_block*)(block))->info.size + END_MAGIC_SIZE)
493     +
494     +# define SUHOSIN_MM_SET_END_CANARY(block) do { \
495     + size_t *p = SUHOSIN_MM_END_CANARY_PTR(block); \
496     + memcpy(p, &heap->canary_3, CANARY_SIZE); \
497     + } while (0)
498     +
499     +#else
500     +
501     +# define SUHOSIN_MM_CHECK_CANARIES(block)
502     +
503     +# define SUHOSIN_MM_SET_CANARIES(block)
504     +
505     +# define SUHOSIN_MM_END_CANARY_PTR(block)
506     +
507     +# define SUHOSIN_MM_SET_END_CANARY(block)
508     +
509     +#endif
510     +
511    
512     #if ZEND_MM_HEAP_PROTECTION
513    
514     @@ -790,6 +848,12 @@
515     if (EXPECTED(prev == mm_block)) {
516     zend_mm_free_block **rp, **cp;
517    
518     +#if SUHOSIN_PATCH
519     + if (next != mm_block) {
520     + zend_suhosin_log(S_MEMORY, "heap corrupt on efree() - heap corruption detected");
521     + exit(1);
522     + }
523     +#endif
524     #if ZEND_MM_SAFE_UNLINKING
525     if (UNEXPECTED(next != mm_block)) {
526     zend_mm_panic("zend_mm_heap corrupted");
527     @@ -828,6 +892,12 @@
528     }
529     } else {
530    
531     +#if SUHOSIN_PATCH
532     + if (prev->next_free_block != mm_block || next->prev_free_block != mm_block) {
533     + zend_suhosin_log(S_MEMORY, "linked list corrupt on efree() - heap corruption detected");
534     + exit(1);
535     + }
536     +#endif
537     #if ZEND_MM_SAFE_UNLINKING
538     if (UNEXPECTED(prev->next_free_block != mm_block) || UNEXPECTED(next->prev_free_block != mm_block)) {
539     zend_mm_panic("zend_mm_heap corrupted");
540     @@ -875,6 +945,11 @@
541     heap->large_free_buckets[i] = NULL;
542     }
543     heap->rest_buckets[0] = heap->rest_buckets[1] = ZEND_MM_REST_BUCKET(heap);
544     +#if SUHOSIN_PATCH
545     + heap->canary_1 = zend_canary();
546     + heap->canary_2 = zend_canary();
547     + heap->canary_3 = zend_canary();
548     +#endif
549     }
550    
551     static void zend_mm_del_segment(zend_mm_heap *heap, zend_mm_segment *segment)
552     @@ -1766,6 +1841,11 @@
553     best_fit = heap->cache[index];
554     heap->cache[index] = best_fit->prev_free_block;
555     heap->cached -= true_size;
556     +#if SUHOSIN_PATCH
557     + SUHOSIN_MM_SET_CANARIES(best_fit);
558     + ((zend_mm_block*)best_fit)->info.size = size;
559     + SUHOSIN_MM_SET_END_CANARY(best_fit);
560     +#endif
561     ZEND_MM_CHECK_MAGIC(best_fit, MEM_BLOCK_CACHED);
562     ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 0);
563     return ZEND_MM_DATA_OF(best_fit);
564     @@ -1905,6 +1985,12 @@
565    
566     ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 1);
567    
568     +#if SUHOSIN_PATCH
569     + SUHOSIN_MM_SET_CANARIES(best_fit);
570     + ((zend_mm_block*)best_fit)->info.size = size;
571     + SUHOSIN_MM_SET_END_CANARY(best_fit);
572     +#endif
573     +
574     heap->size += true_size;
575     if (heap->peak < heap->size) {
576     heap->peak = heap->size;
577     @@ -1928,6 +2014,9 @@
578    
579     mm_block = ZEND_MM_HEADER_OF(p);
580     size = ZEND_MM_BLOCK_SIZE(mm_block);
581     +#if SUHOSIN_PATCH
582     + SUHOSIN_MM_CHECK_CANARIES(mm_block, "efree()");
583     +#endif
584     ZEND_MM_CHECK_PROTECTION(mm_block);
585    
586     #if ZEND_DEBUG || ZEND_MM_HEAP_PROTECTION
587     @@ -1990,6 +2079,9 @@
588     mm_block = ZEND_MM_HEADER_OF(p);
589     true_size = ZEND_MM_TRUE_SIZE(size);
590     orig_size = ZEND_MM_BLOCK_SIZE(mm_block);
591     +#if SUHOSIN_PATCH
592     + SUHOSIN_MM_CHECK_CANARIES(mm_block, "erealloc()");
593     +#endif
594     ZEND_MM_CHECK_PROTECTION(mm_block);
595    
596     if (UNEXPECTED(true_size < size)) {
597     @@ -2021,6 +2113,11 @@
598     HANDLE_UNBLOCK_INTERRUPTIONS();
599     }
600     ZEND_MM_SET_DEBUG_INFO(mm_block, size, 0, 0);
601     +#if SUHOSIN_PATCH
602     + SUHOSIN_MM_SET_CANARIES(mm_block);
603     + ((zend_mm_block*)mm_block)->info.size = size;
604     + SUHOSIN_MM_SET_END_CANARY(mm_block);
605     +#endif
606     return p;
607     }
608    
609     @@ -2040,13 +2137,18 @@
610     heap->cache[index] = best_fit->prev_free_block;
611     ZEND_MM_CHECK_MAGIC(best_fit, MEM_BLOCK_CACHED);
612     ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 0);
613     +#if SUHOSIN_PATCH
614     + SUHOSIN_MM_SET_CANARIES(best_fit);
615     + ((zend_mm_block*)best_fit)->info.size = size;
616     + SUHOSIN_MM_SET_END_CANARY(best_fit);
617     +#endif
618    
619     ptr = ZEND_MM_DATA_OF(best_fit);
620    
621     #if ZEND_DEBUG || ZEND_MM_HEAP_PROTECTION
622     memcpy(ptr, p, mm_block->debug.size);
623     #else
624     - memcpy(ptr, p, orig_size - ZEND_MM_ALIGNED_HEADER_SIZE);
625     + memcpy(ptr, p, orig_size - ZEND_MM_ALIGNED_HEADER_SIZE - CANARY_SIZE);
626     #endif
627    
628     heap->cached -= true_size - orig_size;
629     @@ -2104,6 +2206,11 @@
630     if (heap->peak < heap->size) {
631     heap->peak = heap->size;
632     }
633     +#if SUHOSIN_PATCH
634     + SUHOSIN_MM_SET_CANARIES(mm_block);
635     + ((zend_mm_block*)mm_block)->info.size = size;
636     + SUHOSIN_MM_SET_END_CANARY(mm_block);
637     +#endif
638     HANDLE_UNBLOCK_INTERRUPTIONS();
639     return p;
640     } else if (ZEND_MM_IS_FIRST_BLOCK(mm_block) &&
641     @@ -2207,6 +2314,11 @@
642     }
643    
644     HANDLE_UNBLOCK_INTERRUPTIONS();
645     +#if SUHOSIN_PATCH
646     + SUHOSIN_MM_SET_CANARIES(mm_block);
647     + ((zend_mm_block*)mm_block)->info.size = size;
648     + SUHOSIN_MM_SET_END_CANARY(mm_block);
649     +#endif
650     return ZEND_MM_DATA_OF(mm_block);
651     }
652    
653     @@ -2214,7 +2326,7 @@
654     #if ZEND_DEBUG || ZEND_MM_HEAP_PROTECTION
655     memcpy(ptr, p, mm_block->debug.size);
656     #else
657     - memcpy(ptr, p, orig_size - ZEND_MM_ALIGNED_HEADER_SIZE);
658     + memcpy(ptr, p, orig_size - ZEND_MM_ALIGNED_HEADER_SIZE - CANARY_SIZE);
659     #endif
660     _zend_mm_free_int(heap, p ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
661     return ptr;
662     @@ -2477,6 +2589,17 @@
663     zend_mm_shutdown(AG(mm_heap), full_shutdown, silent);
664     }
665    
666     +#if SUHOSIN_PATCH
667     +ZEND_API void suhosin_clear_mm_canaries(TSRMLS_D)
668     +{
669     +/* NOT HERE
670     +
671     + AG(mm_heap)->canary_1 = zend_canary();
672     + AG(mm_heap)->canary_2 = zend_canary();
673     + AG(mm_heap)->canary_3 = zend_canary(); */
674     +}
675     +#endif
676     +
677     static void alloc_globals_ctor(zend_alloc_globals *alloc_globals TSRMLS_DC)
678     {
679     char *tmp;
680     diff -Nura php-5.2.6/Zend/zend_alloc.h suhosin-patch-5.2.6/Zend/zend_alloc.h
681     --- php-5.2.6/Zend/zend_alloc.h 2007-12-31 08:20:02.000000000 +0100
682     +++ suhosin-patch-5.2.6/Zend/zend_alloc.h 2008-05-01 11:54:41.000000000 +0200
683     @@ -128,6 +128,9 @@
684    
685     ZEND_API void start_memory_manager(TSRMLS_D);
686     ZEND_API void shutdown_memory_manager(int silent, int full_shutdown TSRMLS_DC);
687     +#if SUHOSIN_PATCH
688     +ZEND_API void suhosin_clear_mm_canaries(TSRMLS_D);
689     +#endif
690     ZEND_API int is_zend_mm(TSRMLS_D);
691    
692     #if ZEND_DEBUG
693     diff -Nura php-5.2.6/Zend/zend_canary.c suhosin-patch-5.2.6/Zend/zend_canary.c
694     --- php-5.2.6/Zend/zend_canary.c 1970-01-01 01:00:00.000000000 +0100
695     +++ suhosin-patch-5.2.6/Zend/zend_canary.c 2008-05-01 11:54:41.000000000 +0200
696     @@ -0,0 +1,64 @@
697     +/*
698     + +----------------------------------------------------------------------+
699     + | Suhosin-Patch for PHP |
700     + +----------------------------------------------------------------------+
701     + | Copyright (c) 2004-2006 Stefan Esser |
702     + +----------------------------------------------------------------------+
703     + | This source file is subject to version 2.02 of the PHP license, |
704     + | that is bundled with this package in the file LICENSE, and is |
705     + | available at through the world-wide-web at |
706     + | http://www.php.net/license/2_02.txt. |
707     + | If you did not receive a copy of the PHP license and are unable to |
708     + | obtain it through the world-wide-web, please send a note to |
709     + | license@php.net so we can mail you a copy immediately. |
710     + +----------------------------------------------------------------------+
711     + | Author: Stefan Esser <sesser@hardened-php.net> |
712     + +----------------------------------------------------------------------+
713     + */
714     +/* $Id: php5-5.2.6-suhosin-0.9.6.2.patch,v 1.1 2008-08-17 17:36:49 niro Exp $ */
715     +
716     +#include "zend.h"
717     +
718     +#include <stdio.h>
719     +#include <stdlib.h>
720     +
721     +
722     +#if SUHOSIN_PATCH
723     +
724     +static size_t last_canary = 0x73625123;
725     +
726     +/* will be replaced later with more compatible method */
727     +ZEND_API size_t zend_canary()
728     +{
729     + time_t t;
730     + size_t canary;
731     + int fd;
732     +
733     +#ifndef PHP_WIN32
734     + fd = open("/dev/urandom", 0);
735     + if (fd != -1) {
736     + int r = read(fd, &canary, sizeof(canary));
737     + close(fd);
738     + if (r == sizeof(canary)) {
739     + return (canary);
740     + }
741     + }
742     +#endif
743     + /* not good but we never want to do this */
744     + time(&t);
745     + canary = *(unsigned int *)&t + getpid() << 16 + last_canary;
746     + last_canary ^= (canary << 5) | (canary >> (32-5));
747     + return (canary);
748     +}
749     +
750     +#endif
751     +
752     +
753     +/*
754     + * Local variables:
755     + * tab-width: 4
756     + * c-basic-offset: 4
757     + * End:
758     + * vim600: sw=4 ts=4 fdm=marker
759     + * vim<600: sw=4 ts=4
760     + */
761     diff -Nura php-5.2.6/Zend/zend_compile.c suhosin-patch-5.2.6/Zend/zend_compile.c
762     --- php-5.2.6/Zend/zend_compile.c 2008-02-20 13:04:49.000000000 +0100
763     +++ suhosin-patch-5.2.6/Zend/zend_compile.c 2008-05-01 11:54:41.000000000 +0200
764     @@ -54,7 +54,6 @@
765     property_info->name = zend_strndup(property_info->name, property_info->name_length);
766     }
767    
768     -
769     static void zend_destroy_property_info(zend_property_info *property_info)
770     {
771     efree(property_info->name);
772     @@ -68,6 +67,10 @@
773     {
774     free(property_info->name);
775     }
776     +#if SUHOSIN_PATCH
777     +void *suhosin_zend_destroy_property_info_internal = zend_destroy_property_info_internal;
778     +void *suhosin_zend_destroy_property_info = zend_destroy_property_info;
779     +#endif
780    
781     static void build_runtime_defined_function_key(zval *result, char *name, int name_length TSRMLS_DC)
782     {
783     diff -Nura php-5.2.6/Zend/zend_compile.h suhosin-patch-5.2.6/Zend/zend_compile.h
784     --- php-5.2.6/Zend/zend_compile.h 2007-12-31 08:20:02.000000000 +0100
785     +++ suhosin-patch-5.2.6/Zend/zend_compile.h 2008-05-01 11:54:41.000000000 +0200
786     @@ -564,6 +564,11 @@
787    
788     int zendlex(znode *zendlval TSRMLS_DC);
789    
790     +#if SUHOSIN_PATCH
791     +extern void *suhosin_zend_destroy_property_info_internal;
792     +extern void *suhosin_zend_destroy_property_info;
793     +#endif
794     +
795     /* BEGIN: OPCODES */
796    
797     #include "zend_vm_opcodes.h"
798     @@ -686,6 +691,7 @@
799    
800     #define ZEND_RETURNS_FUNCTION 1<<0
801    
802     +
803     END_EXTERN_C()
804    
805     #define ZEND_CLONE_FUNC_NAME "__clone"
806     diff -Nura php-5.2.6/Zend/zend_constants.c suhosin-patch-5.2.6/Zend/zend_constants.c
807     --- php-5.2.6/Zend/zend_constants.c 2008-02-19 13:00:36.000000000 +0100
808     +++ suhosin-patch-5.2.6/Zend/zend_constants.c 2008-05-01 11:54:41.000000000 +0200
809     @@ -110,6 +110,75 @@
810     REGISTER_MAIN_LONG_CONSTANT("E_USER_NOTICE", E_USER_NOTICE, CONST_PERSISTENT | CONST_CS);
811    
812     REGISTER_MAIN_LONG_CONSTANT("E_ALL", E_ALL, CONST_PERSISTENT | CONST_CS);
813     +#if SUHOSIN_PATCH
814     + REGISTER_MAIN_LONG_CONSTANT("S_MEMORY", S_MEMORY, CONST_PERSISTENT | CONST_CS);
815     + REGISTER_MAIN_LONG_CONSTANT("S_VARS", S_VARS, CONST_PERSISTENT | CONST_CS);
816     + REGISTER_MAIN_LONG_CONSTANT("S_FILES", S_FILES, CONST_PERSISTENT | CONST_CS);
817     + REGISTER_MAIN_LONG_CONSTANT("S_INCLUDE", S_INCLUDE, CONST_PERSISTENT | CONST_CS);
818     + REGISTER_MAIN_LONG_CONSTANT("S_SQL", S_SQL, CONST_PERSISTENT | CONST_CS);
819     + REGISTER_MAIN_LONG_CONSTANT("S_EXECUTOR", S_EXECUTOR, CONST_PERSISTENT | CONST_CS);
820     + REGISTER_MAIN_LONG_CONSTANT("S_MAIL", S_MAIL, CONST_PERSISTENT | CONST_CS);
821     + REGISTER_MAIN_LONG_CONSTANT("S_SESSION", S_SESSION, CONST_PERSISTENT | CONST_CS);
822     + REGISTER_MAIN_LONG_CONSTANT("S_MISC", S_MISC, CONST_PERSISTENT | CONST_CS);
823     + REGISTER_MAIN_LONG_CONSTANT("S_INTERNAL", S_INTERNAL, CONST_PERSISTENT | CONST_CS);
824     + REGISTER_MAIN_LONG_CONSTANT("S_ALL", S_ALL, CONST_PERSISTENT | CONST_CS);
825     +
826     + /* error levels */
827     + REGISTER_MAIN_LONG_CONSTANT("LOG_EMERG", LOG_EMERG, CONST_CS | CONST_PERSISTENT); /* system unusable */
828     + REGISTER_MAIN_LONG_CONSTANT("LOG_ALERT", LOG_ALERT, CONST_CS | CONST_PERSISTENT); /* immediate action required */
829     + REGISTER_MAIN_LONG_CONSTANT("LOG_CRIT", LOG_CRIT, CONST_CS | CONST_PERSISTENT); /* critical conditions */
830     + REGISTER_MAIN_LONG_CONSTANT("LOG_ERR", LOG_ERR, CONST_CS | CONST_PERSISTENT);
831     + REGISTER_MAIN_LONG_CONSTANT("LOG_WARNING", LOG_WARNING, CONST_CS | CONST_PERSISTENT);
832     + REGISTER_MAIN_LONG_CONSTANT("LOG_NOTICE", LOG_NOTICE, CONST_CS | CONST_PERSISTENT);
833     + REGISTER_MAIN_LONG_CONSTANT("LOG_INFO", LOG_INFO, CONST_CS | CONST_PERSISTENT);
834     + REGISTER_MAIN_LONG_CONSTANT("LOG_DEBUG", LOG_DEBUG, CONST_CS | CONST_PERSISTENT);
835     + /* facility: type of program logging the message */
836     + REGISTER_MAIN_LONG_CONSTANT("LOG_KERN", LOG_KERN, CONST_CS | CONST_PERSISTENT);
837     + REGISTER_MAIN_LONG_CONSTANT("LOG_USER", LOG_USER, CONST_CS | CONST_PERSISTENT); /* generic user level */
838     + REGISTER_MAIN_LONG_CONSTANT("LOG_MAIL", LOG_MAIL, CONST_CS | CONST_PERSISTENT); /* log to email */
839     + REGISTER_MAIN_LONG_CONSTANT("LOG_DAEMON", LOG_DAEMON, CONST_CS | CONST_PERSISTENT); /* other system daemons */
840     + REGISTER_MAIN_LONG_CONSTANT("LOG_AUTH", LOG_AUTH, CONST_CS | CONST_PERSISTENT);
841     + REGISTER_MAIN_LONG_CONSTANT("LOG_SYSLOG", LOG_SYSLOG, CONST_CS | CONST_PERSISTENT);
842     + REGISTER_MAIN_LONG_CONSTANT("LOG_LPR", LOG_LPR, CONST_CS | CONST_PERSISTENT);
843     +#ifdef LOG_NEWS
844     + /* No LOG_NEWS on HP-UX */
845     + REGISTER_MAIN_LONG_CONSTANT("LOG_NEWS", LOG_NEWS, CONST_CS | CONST_PERSISTENT); /* usenet new */
846     +#endif
847     +#ifdef LOG_UUCP
848     + /* No LOG_UUCP on HP-UX */
849     + REGISTER_MAIN_LONG_CONSTANT("LOG_UUCP", LOG_UUCP, CONST_CS | CONST_PERSISTENT);
850     +#endif
851     +#ifdef LOG_CRON
852     + /* apparently some systems don't have this one */
853     + REGISTER_MAIN_LONG_CONSTANT("LOG_CRON", LOG_CRON, CONST_CS | CONST_PERSISTENT);
854     +#endif
855     +#ifdef LOG_AUTHPRIV
856     + /* AIX doesn't have LOG_AUTHPRIV */
857     + REGISTER_MAIN_LONG_CONSTANT("LOG_AUTHPRIV", LOG_AUTHPRIV, CONST_CS | CONST_PERSISTENT);
858     +#endif
859     +#if !defined(PHP_WIN32) && !defined(NETWARE)
860     + REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL0", LOG_LOCAL0, CONST_CS | CONST_PERSISTENT);
861     + REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL1", LOG_LOCAL1, CONST_CS | CONST_PERSISTENT);
862     + REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL2", LOG_LOCAL2, CONST_CS | CONST_PERSISTENT);
863     + REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL3", LOG_LOCAL3, CONST_CS | CONST_PERSISTENT);
864     + REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL4", LOG_LOCAL4, CONST_CS | CONST_PERSISTENT);
865     + REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL5", LOG_LOCAL5, CONST_CS | CONST_PERSISTENT);
866     + REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL6", LOG_LOCAL6, CONST_CS | CONST_PERSISTENT);
867     + REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL7", LOG_LOCAL7, CONST_CS | CONST_PERSISTENT);
868     +#endif
869     + /* options */
870     + REGISTER_MAIN_LONG_CONSTANT("LOG_PID", LOG_PID, CONST_CS | CONST_PERSISTENT);
871     + REGISTER_MAIN_LONG_CONSTANT("LOG_CONS", LOG_CONS, CONST_CS | CONST_PERSISTENT);
872     + REGISTER_MAIN_LONG_CONSTANT("LOG_ODELAY", LOG_ODELAY, CONST_CS | CONST_PERSISTENT);
873     + REGISTER_MAIN_LONG_CONSTANT("LOG_NDELAY", LOG_NDELAY, CONST_CS | CONST_PERSISTENT);
874     +#ifdef LOG_NOWAIT
875     + REGISTER_MAIN_LONG_CONSTANT("LOG_NOWAIT", LOG_NOWAIT, CONST_CS | CONST_PERSISTENT);
876     +#endif
877     +#ifdef LOG_PERROR
878     + /* AIX doesn't have LOG_PERROR */
879     + REGISTER_MAIN_LONG_CONSTANT("LOG_PERROR", LOG_PERROR, CONST_CS | CONST_PERSISTENT); /*log to stderr*/
880     +#endif
881     +#endif
882    
883     /* true/false constants */
884     {
885     diff -Nura php-5.2.6/Zend/zend_errors.h suhosin-patch-5.2.6/Zend/zend_errors.h
886     --- php-5.2.6/Zend/zend_errors.h 2007-12-31 08:20:02.000000000 +0100
887     +++ suhosin-patch-5.2.6/Zend/zend_errors.h 2008-05-01 11:54:41.000000000 +0200
888     @@ -39,6 +39,20 @@
889     #define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_RECOVERABLE_ERROR)
890     #define E_CORE (E_CORE_ERROR | E_CORE_WARNING)
891    
892     +#if SUHOSIN_PATCH
893     +#define S_MEMORY (1<<0L)
894     +#define S_MISC (1<<1L)
895     +#define S_VARS (1<<2L)
896     +#define S_FILES (1<<3L)
897     +#define S_INCLUDE (1<<4L)
898     +#define S_SQL (1<<5L)
899     +#define S_EXECUTOR (1<<6L)
900     +#define S_MAIL (1<<7L)
901     +#define S_SESSION (1<<8L)
902     +#define S_INTERNAL (1<<29L)
903     +#define S_ALL (S_MEMORY | S_VARS | S_INCLUDE | S_FILES | S_MAIL | S_SESSION | S_MISC | S_SQL | S_EXECUTOR)
904     +#endif
905     +
906     #endif /* ZEND_ERRORS_H */
907    
908     /*
909     diff -Nura php-5.2.6/Zend/zend_hash.c suhosin-patch-5.2.6/Zend/zend_hash.c
910     --- php-5.2.6/Zend/zend_hash.c 2007-12-31 08:20:02.000000000 +0100
911     +++ suhosin-patch-5.2.6/Zend/zend_hash.c 2008-05-01 11:54:41.000000000 +0200
912     @@ -20,6 +20,7 @@
913     /* $Id: php5-5.2.6-suhosin-0.9.6.2.patch,v 1.1 2008-08-17 17:36:49 niro Exp $ */
914    
915     #include "zend.h"
916     +#include "zend_compile.h"
917    
918     #define CONNECT_TO_BUCKET_DLLIST(element, list_head) \
919     (element)->pNext = (list_head); \
920     @@ -132,7 +133,189 @@
921     (p)->pDataPtr=NULL; \
922     }
923    
924     +#if SUHOSIN_PATCH
925     +#ifdef ZTS
926     +MUTEX_T zend_hash_dprot_mx_reader;
927     +MUTEX_T zend_hash_dprot_mx_writer;
928     +unsigned int zend_hash_dprot_reader;
929     +#endif
930     +unsigned int zend_hash_dprot_counter;
931     +unsigned int zend_hash_dprot_curmax;
932     +dtor_func_t *zend_hash_dprot_table = NULL;
933     +
934     +static void zend_hash_dprot_begin_read()
935     +{
936     +#ifdef ZTS
937     + tsrm_mutex_lock(zend_hash_dprot_mx_reader);
938     + if ((++(zend_hash_dprot_reader)) == 1) {
939     + tsrm_mutex_lock(zend_hash_dprot_mx_writer);
940     + }
941     + tsrm_mutex_unlock(zend_hash_dprot_mx_reader);
942     +#endif
943     +}
944     +
945     +static void zend_hash_dprot_end_read()
946     +{
947     +#ifdef ZTS
948     + tsrm_mutex_lock(zend_hash_dprot_mx_reader);
949     + if ((--(zend_hash_dprot_reader)) == 0) {
950     + tsrm_mutex_unlock(zend_hash_dprot_mx_writer);
951     + }
952     + tsrm_mutex_unlock(zend_hash_dprot_mx_reader);
953     +#endif
954     +}
955     +
956     +static void zend_hash_dprot_begin_write()
957     +{
958     +#ifdef ZTS
959     + tsrm_mutex_lock(zend_hash_dprot_mx_writer);
960     +#endif
961     +}
962     +
963     +static void zend_hash_dprot_end_write()
964     +{
965     +#ifdef ZTS
966     + tsrm_mutex_unlock(zend_hash_dprot_mx_writer);
967     +#endif
968     +}
969     +
970     +/*ZEND_API void zend_hash_dprot_dtor()
971     +{
972     +#ifdef ZTS
973     + tsrm_mutex_free(zend_hash_dprot_mx_reader);
974     + tsrm_mutex_free(zend_hash_dprot_mx_writer);
975     +#endif
976     + free(zend_hash_dprot_table);
977     +}*/
978     +
979     +static void zend_hash_add_destructor(dtor_func_t pDestructor)
980     +{
981     + int left, right, mid;
982     + zend_bool found = 0;
983     + unsigned long value;
984     +
985     + if (pDestructor == NULL || pDestructor == ZVAL_PTR_DTOR || pDestructor == ZVAL_INTERNAL_PTR_DTOR
986     + || pDestructor == ZEND_FUNCTION_DTOR || pDestructor == ZEND_CLASS_DTOR) {
987     + return;
988     + }
989     +
990     + if (zend_hash_dprot_table == NULL) {
991     +#ifdef ZTS
992     + zend_hash_dprot_mx_reader = tsrm_mutex_alloc();
993     + zend_hash_dprot_mx_writer = tsrm_mutex_alloc();
994     + zend_hash_dprot_reader = 0;
995     +#endif
996     + zend_hash_dprot_counter = 0;
997     + zend_hash_dprot_curmax = 256;
998     + zend_hash_dprot_table = (dtor_func_t *) malloc(256 * sizeof(dtor_func_t));
999     + }
1000     +
1001     + zend_hash_dprot_begin_write();
1002     +
1003     + if (zend_hash_dprot_counter == 0) {
1004     + zend_hash_dprot_counter++;
1005     + zend_hash_dprot_table[0] = pDestructor;
1006     + } else {
1007     + value = (unsigned long) pDestructor;
1008     + left = 0;
1009     + right = zend_hash_dprot_counter-1;
1010     + mid = 0;
1011     +
1012     + while (left < right) {
1013     + mid = (right - left) >> 1;
1014     + mid += left;
1015     + if ((unsigned long)zend_hash_dprot_table[mid] == value) {
1016     + found = 1;
1017     + break;
1018     + }
1019     + if (value < (unsigned long)zend_hash_dprot_table[mid]) {
1020     + right = mid-1;
1021     + } else {
1022     + left = mid+1;
1023     + }
1024     + }
1025     + if ((unsigned long)zend_hash_dprot_table[left] == value) {
1026     + found = 1;
1027     + }
1028     +
1029     + if (!found) {
1030     +
1031     + if (zend_hash_dprot_counter >= zend_hash_dprot_curmax) {
1032     + zend_hash_dprot_curmax += 256;
1033     + zend_hash_dprot_table = (dtor_func_t *) realloc(zend_hash_dprot_table, zend_hash_dprot_curmax * sizeof(dtor_func_t));
1034     + }
1035     +
1036     + if ((unsigned long)zend_hash_dprot_table[left] < value) {
1037     + memmove(zend_hash_dprot_table+left+2, zend_hash_dprot_table+left+1, (zend_hash_dprot_counter-left-1)*sizeof(dtor_func_t));
1038     + zend_hash_dprot_table[left+1] = pDestructor;
1039     + } else {
1040     + memmove(zend_hash_dprot_table+left+1, zend_hash_dprot_table+left, (zend_hash_dprot_counter-left)*sizeof(dtor_func_t));
1041     + zend_hash_dprot_table[left] = pDestructor;
1042     + }
1043     +
1044     + zend_hash_dprot_counter++;
1045     + }
1046     + }
1047     +
1048     + zend_hash_dprot_end_write();
1049     +}
1050     +
1051     +static void zend_hash_check_destructor(dtor_func_t pDestructor)
1052     +{
1053     + unsigned long value;
1054     +
1055     + if (pDestructor == NULL || pDestructor == ZVAL_PTR_DTOR || pDestructor == ZVAL_INTERNAL_PTR_DTOR
1056     +#ifdef ZEND_ENGINE_2
1057     + || pDestructor == suhosin_zend_destroy_property_info_internal || pDestructor == suhosin_zend_destroy_property_info
1058     +#endif
1059     + || pDestructor == ZEND_FUNCTION_DTOR || pDestructor == ZEND_CLASS_DTOR) {
1060     + return;
1061     + }
1062     +
1063     + zend_hash_dprot_begin_read();
1064     +
1065     + if (zend_hash_dprot_counter > 0) {
1066     + int left, right, mid;
1067     + zend_bool found = 0;
1068     +
1069     + value = (unsigned long) pDestructor;
1070     + left = 0;
1071     + right = zend_hash_dprot_counter-1;
1072     +
1073     + while (left < right) {
1074     + mid = (right - left) >> 1;
1075     + mid += left;
1076     + if ((unsigned long)zend_hash_dprot_table[mid] == value) {
1077     + found = 1;
1078     + break;
1079     + }
1080     + if (value < (unsigned long)zend_hash_dprot_table[mid]) {
1081     + right = mid-1;
1082     + } else {
1083     + left = mid+1;
1084     + }
1085     + }
1086     + if ((unsigned long)zend_hash_dprot_table[left] == value) {
1087     + found = 1;
1088     + }
1089     +
1090     + if (!found) {
1091     + zend_hash_dprot_end_read();
1092     +
1093     + zend_suhosin_log(S_MEMORY, "possible memory corruption detected - unknown Hashtable destructor");
1094     + exit(1);
1095     + return;
1096     + }
1097     +
1098     + }
1099     +
1100     + zend_hash_dprot_end_read();
1101     +}
1102    
1103     +#else
1104     +#define zend_hash_add_destructor(pDestructor) do {} while(0)
1105     +#define zend_hash_check_destructor(pDestructor) do {} while(0)
1106     +#endif
1107    
1108     ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC)
1109     {
1110     @@ -153,6 +336,7 @@
1111    
1112     ht->nTableMask = ht->nTableSize - 1;
1113     ht->pDestructor = pDestructor;
1114     + zend_hash_add_destructor(pDestructor);
1115     ht->arBuckets = NULL;
1116     ht->pListHead = NULL;
1117     ht->pListTail = NULL;
1118     @@ -230,6 +414,8 @@
1119     return FAILURE;
1120     }
1121     #endif
1122     +
1123     + zend_hash_check_destructor(ht->pDestructor);
1124     if (ht->pDestructor) {
1125     ht->pDestructor(p->pData);
1126     }
1127     @@ -295,6 +481,7 @@
1128     return FAILURE;
1129     }
1130     #endif
1131     + zend_hash_check_destructor(ht->pDestructor);
1132     if (ht->pDestructor) {
1133     ht->pDestructor(p->pData);
1134     }
1135     @@ -370,6 +557,7 @@
1136     return FAILURE;
1137     }
1138     #endif
1139     + zend_hash_check_destructor(ht->pDestructor);
1140     if (ht->pDestructor) {
1141     ht->pDestructor(p->pData);
1142     }
1143     @@ -493,6 +681,7 @@
1144     if (ht->pInternalPointer == p) {
1145     ht->pInternalPointer = p->pListNext;
1146     }
1147     + zend_hash_check_destructor(ht->pDestructor);
1148     if (ht->pDestructor) {
1149     ht->pDestructor(p->pData);
1150     }
1151     @@ -518,6 +707,8 @@
1152    
1153     SET_INCONSISTENT(HT_IS_DESTROYING);
1154    
1155     + zend_hash_check_destructor(ht->pDestructor);
1156     +
1157     p = ht->pListHead;
1158     while (p != NULL) {
1159     q = p;
1160     @@ -544,6 +735,8 @@
1161    
1162     SET_INCONSISTENT(HT_CLEANING);
1163    
1164     + zend_hash_check_destructor(ht->pDestructor);
1165     +
1166     p = ht->pListHead;
1167     while (p != NULL) {
1168     q = p;
1169     @@ -607,6 +800,7 @@
1170     ht->nNumOfElements--;
1171     HANDLE_UNBLOCK_INTERRUPTIONS();
1172    
1173     + zend_hash_check_destructor(ht->pDestructor);
1174     if (ht->pDestructor) {
1175     ht->pDestructor(p->pData);
1176     }
1177     diff -Nura php-5.2.6/Zend/zend_llist.c suhosin-patch-5.2.6/Zend/zend_llist.c
1178     --- php-5.2.6/Zend/zend_llist.c 2007-12-31 08:20:03.000000000 +0100
1179     +++ suhosin-patch-5.2.6/Zend/zend_llist.c 2008-05-01 11:54:41.000000000 +0200
1180     @@ -23,6 +23,184 @@
1181     #include "zend_llist.h"
1182     #include "zend_qsort.h"
1183    
1184     +#if SUHOSIN_PATCH
1185     +#ifdef ZTS
1186     +MUTEX_T zend_llist_dprot_mx_reader;
1187     +MUTEX_T zend_llist_dprot_mx_writer;
1188     +unsigned int zend_llist_dprot_reader;
1189     +#endif
1190     +unsigned int zend_llist_dprot_counter;
1191     +unsigned int zend_llist_dprot_curmax;
1192     +llist_dtor_func_t *zend_llist_dprot_table = NULL;
1193     +
1194     +static void zend_llist_dprot_begin_read()
1195     +{
1196     +#ifdef ZTS
1197     + tsrm_mutex_lock(zend_llist_dprot_mx_reader);
1198     + if ((++(zend_llist_dprot_reader)) == 1) {
1199     + tsrm_mutex_lock(zend_llist_dprot_mx_writer);
1200     + }
1201     + tsrm_mutex_unlock(zend_llist_dprot_mx_reader);
1202     +#endif
1203     +}
1204     +
1205     +static void zend_llist_dprot_end_read()
1206     +{
1207     +#ifdef ZTS
1208     + tsrm_mutex_lock(zend_llist_dprot_mx_reader);
1209     + if ((--(zend_llist_dprot_reader)) == 0) {
1210     + tsrm_mutex_unlock(zend_llist_dprot_mx_writer);
1211     + }
1212     + tsrm_mutex_unlock(zend_llist_dprot_mx_reader);
1213     +#endif
1214     +}
1215     +
1216     +static void zend_llist_dprot_begin_write()
1217     +{
1218     +#ifdef ZTS
1219     + tsrm_mutex_lock(zend_llist_dprot_mx_writer);
1220     +#endif
1221     +}
1222     +
1223     +static void zend_llist_dprot_end_write()
1224     +{
1225     +#ifdef ZTS
1226     + tsrm_mutex_unlock(zend_llist_dprot_mx_writer);
1227     +#endif
1228     +}
1229     +
1230     +/*ZEND_API void zend_llist_dprot_dtor()
1231     +{
1232     +#ifdef ZTS
1233     + tsrm_mutex_free(zend_llist_dprot_mx_reader);
1234     + tsrm_mutex_free(zend_llist_dprot_mx_writer);
1235     +#endif
1236     + free(zend_llist_dprot_table);
1237     +}*/
1238     +
1239     +static void zend_llist_add_destructor(llist_dtor_func_t pDestructor)
1240     +{
1241     + int left, right, mid;
1242     + zend_bool found = 0;
1243     + unsigned long value;
1244     +
1245     + if (pDestructor == NULL || pDestructor == ZVAL_PTR_DTOR) {
1246     + return;
1247     + }
1248     +
1249     + if (zend_llist_dprot_table == NULL) {
1250     +#ifdef ZTS
1251     + zend_llist_dprot_mx_reader = tsrm_mutex_alloc();
1252     + zend_llist_dprot_mx_writer = tsrm_mutex_alloc();
1253     + zend_llist_dprot_reader = 0;
1254     +#endif
1255     + zend_llist_dprot_counter = 0;
1256     + zend_llist_dprot_curmax = 256;
1257     + zend_llist_dprot_table = (llist_dtor_func_t *) malloc(256 * sizeof(llist_dtor_func_t));
1258     + }
1259     +
1260     + zend_llist_dprot_begin_write();
1261     +
1262     + if (zend_llist_dprot_counter == 0) {
1263     + zend_llist_dprot_counter++;
1264     + zend_llist_dprot_table[0] = pDestructor;
1265     + } else {
1266     + value = (unsigned long) pDestructor;
1267     + left = 0;
1268     + right = zend_llist_dprot_counter-1;
1269     + mid = 0;
1270     +
1271     + while (left < right) {
1272     + mid = (right - left) >> 1;
1273     + mid += left;
1274     + if ((unsigned long)zend_llist_dprot_table[mid] == value) {
1275     + found = 1;
1276     + break;
1277     + }
1278     + if (value < (unsigned long)zend_llist_dprot_table[mid]) {
1279     + right = mid-1;
1280     + } else {
1281     + left = mid+1;
1282     + }
1283     + }
1284     + if ((unsigned long)zend_llist_dprot_table[left] == value) {
1285     + found = 1;
1286     + }
1287     +
1288     + if (!found) {
1289     +
1290     + if (zend_llist_dprot_counter >= zend_llist_dprot_curmax) {
1291     + zend_llist_dprot_curmax += 256;
1292     + zend_llist_dprot_table = (llist_dtor_func_t *) realloc(zend_llist_dprot_table, zend_llist_dprot_curmax * sizeof(llist_dtor_func_t));
1293     + }
1294     +
1295     + if ((unsigned long)zend_llist_dprot_table[left] < value) {
1296     + memmove(zend_llist_dprot_table+left+2, zend_llist_dprot_table+left+1, (zend_llist_dprot_counter-left-1)*sizeof(llist_dtor_func_t));
1297     + zend_llist_dprot_table[left+1] = pDestructor;
1298     + } else {
1299     + memmove(zend_llist_dprot_table+left+1, zend_llist_dprot_table+left, (zend_llist_dprot_counter-left)*sizeof(llist_dtor_func_t));
1300     + zend_llist_dprot_table[left] = pDestructor;
1301     + }
1302     +
1303     + zend_llist_dprot_counter++;
1304     + }
1305     + }
1306     +
1307     + zend_llist_dprot_end_write();
1308     +}
1309     +
1310     +static void zend_llist_check_destructor(llist_dtor_func_t pDestructor)
1311     +{
1312     + unsigned long value;
1313     +
1314     + if (pDestructor == NULL || pDestructor == ZVAL_PTR_DTOR) {
1315     + return;
1316     + }
1317     +
1318     + zend_llist_dprot_begin_read();
1319     +
1320     + if (zend_llist_dprot_counter > 0) {
1321     + int left, right, mid;
1322     + zend_bool found = 0;
1323     +
1324     + value = (unsigned long) pDestructor;
1325     + left = 0;
1326     + right = zend_llist_dprot_counter-1;
1327     +
1328     + while (left < right) {
1329     + mid = (right - left) >> 1;
1330     + mid += left;
1331     + if ((unsigned long)zend_llist_dprot_table[mid] == value) {
1332     + found = 1;
1333     + break;
1334     + }
1335     + if (value < (unsigned long)zend_llist_dprot_table[mid]) {
1336     + right = mid-1;
1337     + } else {
1338     + left = mid+1;
1339     + }
1340     + }
1341     + if ((unsigned long)zend_llist_dprot_table[left] == value) {
1342     + found = 1;
1343     + }
1344     +
1345     + if (!found) {
1346     + zend_llist_dprot_end_read();
1347     +
1348     + zend_suhosin_log(S_MEMORY, "possible memory corruption detected - unknown llist destructor");
1349     + exit(1);
1350     + return;
1351     + }
1352     +
1353     + }
1354     +
1355     + zend_llist_dprot_end_read();
1356     +}
1357     +#else
1358     +#define zend_llist_add_destructor(pDestructor) do {} while(0)
1359     +#define zend_llist_check_destructor(pDestructor) do {} while(0)
1360     +#endif
1361     +
1362     ZEND_API void zend_llist_init(zend_llist *l, size_t size, llist_dtor_func_t dtor, unsigned char persistent)
1363     {
1364     l->head = NULL;
1365     @@ -30,6 +208,7 @@
1366     l->count = 0;
1367     l->size = size;
1368     l->dtor = dtor;
1369     + zend_llist_add_destructor(dtor);
1370     l->persistent = persistent;
1371     }
1372    
1373     @@ -81,6 +260,7 @@
1374     } else {\
1375     (l)->tail = (current)->prev;\
1376     }\
1377     + zend_llist_check_destructor((l)->dtor); \
1378     if ((l)->dtor) {\
1379     (l)->dtor((current)->data);\
1380     }\
1381     @@ -108,6 +288,7 @@
1382     {
1383     zend_llist_element *current=l->head, *next;
1384    
1385     + zend_llist_check_destructor(l->dtor);
1386     while (current) {
1387     next = current->next;
1388     if (l->dtor) {
1389     @@ -133,6 +314,7 @@
1390     zend_llist_element *old_tail;
1391     void *data;
1392    
1393     + zend_llist_check_destructor(l->dtor);
1394     if ((old_tail = l->tail)) {
1395     if (old_tail->prev) {
1396     old_tail->prev->next = NULL;
1397     diff -Nura php-5.2.6/configure suhosin-patch-5.2.6/configure
1398     --- php-5.2.6/configure 2008-04-30 20:37:32.000000000 +0200
1399     +++ suhosin-patch-5.2.6/configure 2008-05-01 11:54:41.000000000 +0200
1400     @@ -18496,6 +18496,9 @@
1401    
1402     fi
1403    
1404     +cat >> confdefs.h <<\EOF
1405     +#define SUHOSIN_PATCH 1
1406     +EOF
1407    
1408     echo $ac_n "checking for declared timezone""... $ac_c" 1>&6
1409     echo "configure:18502: checking for declared timezone" >&5
1410     @@ -115757,7 +115760,7 @@
1411     php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
1412     strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c \
1413     network.c php_open_temporary_file.c php_logos.c \
1414     - output.c ; do
1415     + output.c suhosin_patch.c ; do
1416    
1417     IFS=.
1418     set $ac_src
1419     @@ -115959,7 +115962,7 @@
1420     zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \
1421     zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \
1422     zend_ini.c zend_qsort.c zend_multibyte.c zend_ts_hash.c zend_stream.c \
1423     - zend_iterators.c zend_interfaces.c zend_exceptions.c zend_strtod.c; do
1424     + zend_iterators.c zend_interfaces.c zend_exceptions.c zend_strtod.c zend_canary.c; do
1425    
1426     IFS=.
1427     set $ac_src
1428     diff -Nura php-5.2.6/configure.in suhosin-patch-5.2.6/configure.in
1429     --- php-5.2.6/configure.in 2008-04-30 20:27:55.000000000 +0200
1430     +++ suhosin-patch-5.2.6/configure.in 2008-05-01 11:54:41.000000000 +0200
1431     @@ -227,6 +227,7 @@
1432     sinclude(TSRM/threads.m4)
1433     sinclude(TSRM/tsrm.m4)
1434    
1435     +sinclude(main/suhosin_patch.m4)
1436    
1437     divert(2)
1438    
1439     @@ -1301,7 +1302,7 @@
1440     php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
1441     strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c \
1442     network.c php_open_temporary_file.c php_logos.c \
1443     - output.c )
1444     + output.c suhosin_patch.c )
1445    
1446     PHP_ADD_SOURCES(main/streams, streams.c cast.c memory.c filter.c \
1447     plain_wrapper.c userspace.c transports.c xp_socket.c mmap.c)
1448     @@ -1327,7 +1328,7 @@
1449     zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \
1450     zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \
1451     zend_ini.c zend_qsort.c zend_multibyte.c zend_ts_hash.c zend_stream.c \
1452     - zend_iterators.c zend_interfaces.c zend_exceptions.c zend_strtod.c)
1453     + zend_iterators.c zend_interfaces.c zend_exceptions.c zend_strtod.c zend_canary.c )
1454    
1455     if test -r "$abs_srcdir/Zend/zend_objects.c"; then
1456     PHP_ADD_SOURCES(Zend, zend_objects.c zend_object_handlers.c zend_objects_API.c \
1457     diff -Nura php-5.2.6/ext/standard/basic_functions.c suhosin-patch-5.2.6/ext/standard/basic_functions.c
1458     --- php-5.2.6/ext/standard/basic_functions.c 2008-03-20 01:55:26.000000000 +0100
1459     +++ suhosin-patch-5.2.6/ext/standard/basic_functions.c 2008-05-01 11:54:41.000000000 +0200
1460     @@ -3575,7 +3575,9 @@
1461     PHP_FALIAS(socket_get_status, stream_get_meta_data, arginfo_stream_get_meta_data)
1462    
1463     #if (!defined(__BEOS__) && !defined(NETWARE) && HAVE_REALPATH) || defined(ZTS)
1464     - PHP_FE(realpath, arginfo_realpath)
1465     +#undef realpath
1466     + PHP_NAMED_FE(realpath, PHP_FN(real_path), arginfo_realpath)
1467     +#define realpath real_path
1468     #endif
1469    
1470     #ifdef HAVE_FNMATCH
1471     diff -Nura php-5.2.6/ext/standard/dl.c suhosin-patch-5.2.6/ext/standard/dl.c
1472     --- php-5.2.6/ext/standard/dl.c 2007-12-31 08:20:12.000000000 +0100
1473     +++ suhosin-patch-5.2.6/ext/standard/dl.c 2008-05-01 11:54:41.000000000 +0200
1474     @@ -246,6 +246,19 @@
1475     RETURN_FALSE;
1476     }
1477     }
1478     +#if SUHOSIN_PATCH
1479     + if (strncmp("suhosin", module_entry->name, sizeof("suhosin")-1) == 0) {
1480     + void *log_func;
1481     + /* sucessfully loaded suhosin extension, now check for logging function replacement */
1482     + log_func = (void *) DL_FETCH_SYMBOL(handle, "suhosin_log");
1483     + if (log_func == NULL) {
1484     + log_func = (void *) DL_FETCH_SYMBOL(handle, "_suhosin_log");
1485     + }
1486     + if (log_func != NULL) {
1487     + zend_suhosin_log = log_func;
1488     + }
1489     + }
1490     +#endif
1491     RETURN_TRUE;
1492     }
1493     /* }}} */
1494     diff -Nura php-5.2.6/ext/standard/file.c suhosin-patch-5.2.6/ext/standard/file.c
1495     --- php-5.2.6/ext/standard/file.c 2007-12-31 08:20:12.000000000 +0100
1496     +++ suhosin-patch-5.2.6/ext/standard/file.c 2008-05-01 11:54:41.000000000 +0200
1497     @@ -2372,7 +2372,7 @@
1498     #if (!defined(__BEOS__) && !defined(NETWARE) && HAVE_REALPATH) || defined(ZTS)
1499     /* {{{ proto string realpath(string path)
1500     Return the resolved path */
1501     -PHP_FUNCTION(realpath)
1502     +PHP_FUNCTION(real_path)
1503     {
1504     zval **path;
1505     char resolved_path_buff[MAXPATHLEN];
1506     diff -Nura php-5.2.6/ext/standard/file.h suhosin-patch-5.2.6/ext/standard/file.h
1507     --- php-5.2.6/ext/standard/file.h 2007-12-31 08:20:12.000000000 +0100
1508     +++ suhosin-patch-5.2.6/ext/standard/file.h 2008-05-01 11:54:41.000000000 +0200
1509     @@ -61,7 +61,7 @@
1510     PHP_FUNCTION(fd_set);
1511     PHP_FUNCTION(fd_isset);
1512     #if (!defined(__BEOS__) && !defined(NETWARE) && HAVE_REALPATH) || defined(ZTS)
1513     -PHP_FUNCTION(realpath);
1514     +PHP_FUNCTION(real_path);
1515     #endif
1516     #ifdef HAVE_FNMATCH
1517     PHP_FUNCTION(fnmatch);
1518     diff -Nura php-5.2.6/ext/standard/info.c suhosin-patch-5.2.6/ext/standard/info.c
1519     --- php-5.2.6/ext/standard/info.c 2008-03-05 22:09:29.000000000 +0100
1520     +++ suhosin-patch-5.2.6/ext/standard/info.c 2008-05-01 11:54:41.000000000 +0200
1521     @@ -652,6 +652,31 @@
1522    
1523     php_info_print_table_end();
1524    
1525     + /* Suhosin Patch */
1526     + php_info_print_box_start(0);
1527     + if (expose_php && !sapi_module.phpinfo_as_text) {
1528     + PUTS("<a href=\"http://www.hardened-php.net/suhosin/index.html\"><img border=\"0\" src=\"");
1529     + if (SG(request_info).request_uri) {
1530     + char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
1531     + PUTS(elem_esc);
1532     + efree(elem_esc);
1533     + }
1534     + PUTS("?="SUHOSIN_LOGO_GUID"\" alt=\"Suhosin logo\" /></a>\n");
1535     + }
1536     + PUTS("This server is protected with the Suhosin Patch ");
1537     + if (sapi_module.phpinfo_as_text) {
1538     + PUTS(SUHOSIN_PATCH_VERSION);
1539     + } else {
1540     + zend_html_puts(SUHOSIN_PATCH_VERSION, strlen(SUHOSIN_PATCH_VERSION) TSRMLS_CC);
1541     + }
1542     + PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n");
1543     + if (sapi_module.phpinfo_as_text) {
1544     + PUTS("Copyright (c) 2006 Hardened-PHP Project\n");
1545     + } else {
1546     + PUTS("Copyright (c) 2006 <a href=\"http://www.hardened-php.net/\">Hardened-PHP Project</a>\n");
1547     + }
1548     + php_info_print_box_end();
1549     +
1550     /* Zend Engine */
1551     php_info_print_box_start(0);
1552     if (expose_php && !sapi_module.phpinfo_as_text) {
1553     diff -Nura php-5.2.6/ext/standard/syslog.c suhosin-patch-5.2.6/ext/standard/syslog.c
1554     --- php-5.2.6/ext/standard/syslog.c 2008-02-20 16:28:37.000000000 +0100
1555     +++ suhosin-patch-5.2.6/ext/standard/syslog.c 2008-05-01 11:54:41.000000000 +0200
1556     @@ -42,6 +42,7 @@
1557     */
1558     PHP_MINIT_FUNCTION(syslog)
1559     {
1560     +#if !SUHOSIN_PATCH
1561     /* error levels */
1562     REGISTER_LONG_CONSTANT("LOG_EMERG", LOG_EMERG, CONST_CS | CONST_PERSISTENT); /* system unusable */
1563     REGISTER_LONG_CONSTANT("LOG_ALERT", LOG_ALERT, CONST_CS | CONST_PERSISTENT); /* immediate action required */
1564     @@ -97,6 +98,7 @@
1565     /* AIX doesn't have LOG_PERROR */
1566     REGISTER_LONG_CONSTANT("LOG_PERROR", LOG_PERROR, CONST_CS | CONST_PERSISTENT); /*log to stderr*/
1567     #endif
1568     +#endif
1569     BG(syslog_device)=NULL;
1570    
1571     return SUCCESS;
1572     diff -Nura php-5.2.6/main/fopen_wrappers.c suhosin-patch-5.2.6/main/fopen_wrappers.c
1573     --- php-5.2.6/main/fopen_wrappers.c 2008-01-29 15:23:19.000000000 +0100
1574     +++ suhosin-patch-5.2.6/main/fopen_wrappers.c 2008-05-01 11:54:41.000000000 +0200
1575     @@ -110,7 +110,7 @@
1576    
1577     /* normalize and expand path */
1578     if (expand_filepath(path, resolved_name TSRMLS_CC) == NULL) {
1579     - return -1;
1580     + return -2;
1581     }
1582    
1583     path_len = strlen(resolved_name);
1584     @@ -182,6 +182,12 @@
1585     }
1586     }
1587    
1588     + if (resolved_name_len == resolved_basedir_len - 1) {
1589     + if (resolved_basedir[resolved_basedir_len - 1] == PHP_DIR_SEPARATOR) {
1590     + resolved_basedir_len--;
1591     + }
1592     + }
1593     +
1594     /* Check the path */
1595     #if defined(PHP_WIN32) || defined(NETWARE)
1596     if (strncasecmp(resolved_basedir, resolved_name, resolved_basedir_len) == 0) {
1597     @@ -205,7 +211,7 @@
1598     }
1599     } else {
1600     /* Unable to resolve the real path, return -1 */
1601     - return -1;
1602     + return -3;
1603     }
1604     }
1605     /* }}} */
1606     @@ -224,22 +230,44 @@
1607     char *pathbuf;
1608     char *ptr;
1609     char *end;
1610     + char path_copy[MAXPATHLEN];
1611     + int path_len;
1612     +
1613     + /* Special case path ends with a trailing slash */
1614     + path_len = strlen(path);
1615     + if (path_len >= MAXPATHLEN) {
1616     + errno = EPERM; /* we deny permission to open it */
1617     + return -1;
1618     + }
1619     + if (path_len > 0 && path[path_len-1] == PHP_DIR_SEPARATOR) {
1620     + memcpy(path_copy, path, path_len+1);
1621     + while (path_len > 1 && path_copy[path_len-1] == PHP_DIR_SEPARATOR) path_len--;
1622     + path_copy[path_len] = '\0';
1623     + path = (const char *)&path_copy;
1624     + }
1625    
1626     pathbuf = estrdup(PG(open_basedir));
1627    
1628     ptr = pathbuf;
1629    
1630     while (ptr && *ptr) {
1631     + int res;
1632     end = strchr(ptr, DEFAULT_DIR_SEPARATOR);
1633     if (end != NULL) {
1634     *end = '\0';
1635     end++;
1636     }
1637    
1638     - if (php_check_specific_open_basedir(ptr, path TSRMLS_CC) == 0) {
1639     + res = php_check_specific_open_basedir(ptr, path TSRMLS_CC);
1640     + if (res == 0) {
1641     efree(pathbuf);
1642     return 0;
1643     }
1644     + if (res == -2) {
1645     + efree(pathbuf);
1646     + errno = EPERM;
1647     + return -1;
1648     + }
1649    
1650     ptr = end;
1651     }
1652     diff -Nura php-5.2.6/main/main.c suhosin-patch-5.2.6/main/main.c
1653     --- php-5.2.6/main/main.c 2008-03-05 21:58:08.000000000 +0100
1654     +++ suhosin-patch-5.2.6/main/main.c 2008-05-01 11:54:41.000000000 +0200
1655     @@ -89,6 +89,9 @@
1656    
1657     #include "SAPI.h"
1658     #include "rfc1867.h"
1659     +#if SUHOSIN_PATCH
1660     +#include "suhosin_globals.h"
1661     +#endif
1662     /* }}} */
1663    
1664     #ifndef ZTS
1665     @@ -1370,7 +1373,7 @@
1666    
1667     /* used to close fd's in the 3..255 range here, but it's problematic
1668     */
1669     - shutdown_memory_manager(1, 1 TSRMLS_CC);
1670     + shutdown_memory_manager(1, 1 TSRMLS_CC);
1671     }
1672     /* }}} */
1673    
1674     @@ -1411,6 +1414,9 @@
1675    
1676     zend_try {
1677     shutdown_memory_manager(CG(unclean_shutdown), 0 TSRMLS_CC);
1678     +#if SUHOSIN_PATCH
1679     + suhosin_clear_mm_canaries(TSRMLS_C);
1680     +#endif
1681     } zend_end_try();
1682    
1683     zend_try {
1684     @@ -1503,6 +1509,9 @@
1685     /* 11. Free Willy (here be crashes) */
1686     zend_try {
1687     shutdown_memory_manager(CG(unclean_shutdown) || !report_memleaks, 0 TSRMLS_CC);
1688     +#if SUHOSIN_PATCH
1689     + suhosin_clear_mm_canaries(TSRMLS_C);
1690     +#endif
1691     } zend_end_try();
1692    
1693     /* 12. Reset max_execution_time */
1694     @@ -1662,6 +1671,9 @@
1695     #ifdef ZTS
1696     tsrm_ls = ts_resource(0);
1697     #endif
1698     +#if SUHOSIN_PATCH
1699     + suhosin_startup();
1700     +#endif
1701    
1702     module_shutdown = 0;
1703     module_startup = 1;
1704     @@ -1791,6 +1803,10 @@
1705     REGISTER_MAIN_STRINGL_CONSTANT("PHP_CONFIG_FILE_PATH", PHP_CONFIG_FILE_PATH, strlen(PHP_CONFIG_FILE_PATH), CONST_PERSISTENT | CONST_CS);
1706     REGISTER_MAIN_STRINGL_CONSTANT("PHP_CONFIG_FILE_SCAN_DIR", PHP_CONFIG_FILE_SCAN_DIR, sizeof(PHP_CONFIG_FILE_SCAN_DIR)-1, CONST_PERSISTENT | CONST_CS);
1707     REGISTER_MAIN_STRINGL_CONSTANT("PHP_SHLIB_SUFFIX", PHP_SHLIB_SUFFIX, sizeof(PHP_SHLIB_SUFFIX)-1, CONST_PERSISTENT | CONST_CS);
1708     +#if SUHOSIN_PATCH
1709     + REGISTER_MAIN_LONG_CONSTANT("SUHOSIN_PATCH", 1, CONST_PERSISTENT | CONST_CS);
1710     + REGISTER_MAIN_STRINGL_CONSTANT("SUHOSIN_PATCH_VERSION", SUHOSIN_PATCH_VERSION, sizeof(SUHOSIN_PATCH_VERSION)-1, CONST_PERSISTENT | CONST_CS);
1711     +#endif
1712     REGISTER_MAIN_STRINGL_CONSTANT("PHP_EOL", PHP_EOL, sizeof(PHP_EOL)-1, CONST_PERSISTENT | CONST_CS);
1713     REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MAX", LONG_MAX, CONST_PERSISTENT | CONST_CS);
1714     REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", sizeof(long), CONST_PERSISTENT | CONST_CS);
1715     @@ -1840,7 +1856,9 @@
1716     module_startup = 0;
1717    
1718     shutdown_memory_manager(1, 0 TSRMLS_CC);
1719     -
1720     +#if SUHOSIN_PATCH
1721     + suhosin_clear_mm_canaries(TSRMLS_C);
1722     +#endif
1723     /* we're done */
1724     return SUCCESS;
1725     }
1726     @@ -1899,6 +1917,9 @@
1727     #ifndef ZTS
1728     zend_ini_shutdown(TSRMLS_C);
1729     shutdown_memory_manager(CG(unclean_shutdown), 1 TSRMLS_CC);
1730     +#if SUHOSIN_PATCH
1731     + suhosin_clear_mm_canaries(TSRMLS_C);
1732     +#endif
1733     core_globals_dtor(&core_globals TSRMLS_CC);
1734     #else
1735     zend_ini_global_shutdown(TSRMLS_C);
1736     diff -Nura php-5.2.6/main/php.h suhosin-patch-5.2.6/main/php.h
1737     --- php-5.2.6/main/php.h 2007-12-31 08:20:15.000000000 +0100
1738     +++ suhosin-patch-5.2.6/main/php.h 2008-05-01 11:54:41.000000000 +0200
1739     @@ -40,6 +40,13 @@
1740     #undef sprintf
1741     #define sprintf php_sprintf
1742    
1743     +#if SUHOSIN_PATCH
1744     +#if HAVE_REALPATH
1745     +#undef realpath
1746     +#define realpath php_realpath
1747     +#endif
1748     +#endif
1749     +
1750     /* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
1751     #undef PHP_DEBUG
1752     #define PHP_DEBUG ZEND_DEBUG
1753     @@ -448,6 +455,10 @@
1754     #endif
1755     #endif /* !XtOffsetOf */
1756    
1757     +#if SUHOSIN_PATCH
1758     +#include "suhosin_patch.h"
1759     +#endif
1760     +
1761     #endif
1762    
1763     /*
1764     diff -Nura php-5.2.6/main/php_config.h.in suhosin-patch-5.2.6/main/php_config.h.in
1765     --- php-5.2.6/main/php_config.h.in 2008-04-30 20:37:39.000000000 +0200
1766     +++ suhosin-patch-5.2.6/main/php_config.h.in 2008-05-01 11:54:41.000000000 +0200
1767     @@ -803,6 +803,9 @@
1768     /* Define if the target system has /dev/urandom device */
1769     #undef HAVE_DEV_URANDOM
1770    
1771     +/* Suhosin-Patch for PHP */
1772     +#undef SUHOSIN_PATCH
1773     +
1774     /* Whether you have AOLserver */
1775     #undef HAVE_AOLSERVER
1776    
1777     diff -Nura php-5.2.6/main/php_logos.c suhosin-patch-5.2.6/main/php_logos.c
1778     --- php-5.2.6/main/php_logos.c 2007-12-31 08:20:15.000000000 +0100
1779     +++ suhosin-patch-5.2.6/main/php_logos.c 2008-05-01 11:54:41.000000000 +0200
1780     @@ -50,6 +50,10 @@
1781     return zend_hash_del(&phpinfo_logo_hash, logo_string, strlen(logo_string));
1782     }
1783    
1784     +#if SUHOSIN_PATCH
1785     +#include "suhosin_logo.h"
1786     +#endif
1787     +
1788     int php_init_info_logos(void)
1789     {
1790     if(zend_hash_init(&phpinfo_logo_hash, 0, NULL, NULL, 1)==FAILURE)
1791     @@ -58,6 +62,9 @@
1792     php_register_info_logo(PHP_LOGO_GUID , "image/gif", php_logo , sizeof(php_logo));
1793     php_register_info_logo(PHP_EGG_LOGO_GUID, "image/gif", php_egg_logo, sizeof(php_egg_logo));
1794     php_register_info_logo(ZEND_LOGO_GUID , "image/gif", zend_logo , sizeof(zend_logo));
1795     +#if SUHOSIN_PATCH
1796     + php_register_info_logo(SUHOSIN_LOGO_GUID, "image/jpeg", suhosin_logo, sizeof(suhosin_logo));
1797     +#endif
1798    
1799     return SUCCESS;
1800     }
1801     diff -Nura php-5.2.6/main/snprintf.c suhosin-patch-5.2.6/main/snprintf.c
1802     --- php-5.2.6/main/snprintf.c 2007-12-31 08:20:15.000000000 +0100
1803     +++ suhosin-patch-5.2.6/main/snprintf.c 2008-05-01 11:54:41.000000000 +0200
1804     @@ -1080,7 +1080,11 @@
1805    
1806    
1807     case 'n':
1808     +#if SUHOSIN_PATCH
1809     + zend_suhosin_log(S_MISC, "'n' specifier within format string");
1810     +#else
1811     *(va_arg(ap, int *)) = cc;
1812     +#endif
1813     goto skip_output;
1814    
1815     /*
1816     diff -Nura php-5.2.6/main/spprintf.c suhosin-patch-5.2.6/main/spprintf.c
1817     --- php-5.2.6/main/spprintf.c 2007-12-31 08:20:15.000000000 +0100
1818     +++ suhosin-patch-5.2.6/main/spprintf.c 2008-05-01 11:54:41.000000000 +0200
1819     @@ -673,7 +673,11 @@
1820    
1821    
1822     case 'n':
1823     +#if SUHOSIN_PATCH
1824     + zend_suhosin_log(S_MISC, "'n' specifier within format string");
1825     +#else
1826     *(va_arg(ap, int *)) = xbuf->len;
1827     +#endif
1828     goto skip_output;
1829    
1830     /*
1831     diff -Nura php-5.2.6/main/suhosin_globals.h suhosin-patch-5.2.6/main/suhosin_globals.h
1832     --- php-5.2.6/main/suhosin_globals.h 1970-01-01 01:00:00.000000000 +0100
1833     +++ suhosin-patch-5.2.6/main/suhosin_globals.h 2008-05-01 11:54:41.000000000 +0200
1834     @@ -0,0 +1,61 @@
1835     +/*
1836     + +----------------------------------------------------------------------+
1837     + | Suhosin-Patch for PHP |
1838     + +----------------------------------------------------------------------+
1839     + | Copyright (c) 2004-2006 Stefan Esser |
1840     + +----------------------------------------------------------------------+
1841     + | This source file is subject to version 2.02 of the PHP license, |
1842     + | that is bundled with this package in the file LICENSE, and is |
1843     + | available at through the world-wide-web at |
1844     + | http://www.php.net/license/2_02.txt. |
1845     + | If you did not receive a copy of the PHP license and are unable to |
1846     + | obtain it through the world-wide-web, please send a note to |
1847     + | license@php.net so we can mail you a copy immediately. |
1848     + +----------------------------------------------------------------------+
1849     + | Author: Stefan Esser <sesser@hardened-php.net> |
1850     + +----------------------------------------------------------------------+
1851     + */
1852     +
1853     +#ifndef SUHOSIN_GLOBALS_H
1854     +#define SUHOSIN_GLOBALS_H
1855     +
1856     +typedef struct _suhosin_patch_globals suhosin_patch_globals_struct;
1857     +
1858     +#ifdef ZTS
1859     +# define SPG(v) TSRMG(suhosin_patch_globals_id, suhosin_patch_globals_struct *, v)
1860     +extern int suhosin_patch_globals_id;
1861     +#else
1862     +# define SPG(v) (suhosin_patch_globals.v)
1863     +extern struct _suhosin_patch_globals suhosin_patch_globals;
1864     +#endif
1865     +
1866     +
1867     +struct _suhosin_patch_globals {
1868     + /* logging */
1869     + int log_syslog;
1870     + int log_syslog_facility;
1871     + int log_syslog_priority;
1872     + int log_sapi;
1873     + int log_script;
1874     + int log_phpscript;
1875     + char *log_scriptname;
1876     + char *log_phpscriptname;
1877     + zend_bool log_phpscript_is_safe;
1878     + zend_bool log_use_x_forwarded_for;
1879     +
1880     + /* memory manager canary protection */
1881     + unsigned int canary_1;
1882     + unsigned int canary_2;
1883     + unsigned int canary_3;
1884     + unsigned int dummy;
1885     +};
1886     +
1887     +
1888     +#endif /* SUHOSIN_GLOBALS_H */
1889     +
1890     +/*
1891     + * Local variables:
1892     + * tab-width: 4
1893     + * c-basic-offset: 4
1894     + * End:
1895     + */
1896     diff -Nura php-5.2.6/main/suhosin_logo.h suhosin-patch-5.2.6/main/suhosin_logo.h
1897     --- php-5.2.6/main/suhosin_logo.h 1970-01-01 01:00:00.000000000 +0100
1898     +++ suhosin-patch-5.2.6/main/suhosin_logo.h 2008-05-01 11:54:41.000000000 +0200
1899     @@ -0,0 +1,178 @@
1900     +static unsigned char suhosin_logo[] =
1901     + "\xff\xd8\xff\xe0\x00\x10\x4a\x46\x49\x46\x00\x01\x01\x01\x00\x48"
1902     + "\x00\x48\x00\x00\xff\xe1\x00\x16\x45\x78\x69\x66\x00\x00\x4d\x4d"
1903     + "\x00\x2a\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\xff\xdb\x00\x43"
1904     + "\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
1905     + "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
1906     + "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
1907     + "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
1908     + "\x01\xff\xc0\x00\x0b\x08\x00\x27\x00\x71\x01\x01\x22\x00\xff\xc4"
1909     + "\x00\x1e\x00\x00\x02\x02\x02\x03\x01\x01\x00\x00\x00\x00\x00\x00"
1910     + "\x00\x00\x00\x00\x09\x06\x08\x05\x07\x02\x03\x0a\x01\x04\xff\xc4"
1911     + "\x00\x32\x10\x00\x01\x04\x03\x00\x02\x00\x05\x01\x05\x09\x01\x00"
1912     + "\x00\x00\x00\x05\x02\x03\x04\x06\x01\x07\x08\x00\x09\x11\x12\x13"
1913     + "\x14\x21\x15\x0a\x16\x31\x56\x96\x17\x18\x19\x23\x32\x41\x58\x98"
1914     + "\xd4\xd6\xff\xda\x00\x08\x01\x01\x00\x00\x3f\x00\xf4\xc1\xe1\xe5"
1915     + "\x69\xe9\x3e\xb9\xd1\x7c\x8a\x2e\x9d\x66\xe8\x3b\x29\x4d\x7f\x46"
1916     + "\xba\x58\x55\x54\x8d\xb1\x5f\xaa\xd9\x8d\x51\x2b\xb6\x27\x5a\x69"
1917     + "\xd1\x43\xaf\x16\x1a\xf0\xb2\xb1\xe9\x6d\x9f\xc2\xa4\x36\x18\xb5"
1918     + "\x85\x10\x41\xbe\xfc\x09\xac\x49\x29\x11\xd4\x32\x97\xec\x08\x13"
1919     + "\xc1\x2d\x20\xc3\x59\xeb\x26\x05\xd8\x6b\x76\x31\x43\x8f\x57\xcf"
1920     + "\x84\x9f\x14\xa8\x53\x81\x0b\xc3\x64\x80\xa3\x02\x0a\x41\x75\xf8"
1921     + "\x44\x85\x93\x81\x22\x3c\xd8\x13\xe1\xbe\xf4\x59\x91\x1f\x6a\x44"
1922     + "\x77\x5c\x69\xc4\x2f\x39\x5f\x0f\x2a\x8d\xeb\xba\xf8\xc3\x56\x6c"
1923     + "\x3b\x36\xa7\xda\xbd\x4d\xa1\xb5\x4e\xc6\xa7\xa4\x3a\xec\x15\x2d"
1924     + "\xa5\xb3\xea\x5a\xdc\xac\x46\xac\x01\x60\xd8\x43\xc8\x8e\x8b\xb1"
1925     + "\x40\x4c\x95\x8b\x34\x41\x28\x52\x91\x28\x43\xd3\xa3\xb6\xa7\x55"
1926     + "\x15\xe7\x5a\x96\xcb\xf1\xda\xe5\x55\xee\xfe\x1e\xbd\xd9\x41\xd3"
1927     + "\x28\xfd\x97\xca\x57\x2b\x85\x9c\xa4\x30\x95\xaa\xa5\x57\xa2\x35"
1928     + "\x15\x86\xcb\x61\x34\x41\xe4\xc7\x80\x20\x18\x21\x17\x09\x85\x0b"
1929     + "\x14\x9d\x21\x68\x62\x1c\x08\x11\x64\x4b\x92\xf2\xd2\xd3\x2d\x2d"
1930     + "\x6a\xc2\x73\x6b\x3c\x3c\x8b\x9e\xbc\x52\xaa\xa4\xab\x81\x6c\xf6"
1931     + "\xfa\xbd\x70\xc5\xc6\x7b\xc2\xaa\x22\x4f\x58\x04\x87\x25\x6a\x27"
1932     + "\x1d\xa4\x3d\x20\x75\x72\x01\x09\x71\xe5\x1c\x9e\xc3\x2e\x36\xf3"
1933     + "\xd0\xc6\x35\x2a\x43\x4d\x2d\x0e\x2d\xb4\xa1\x49\xce\x65\x1e\x52"
1934     + "\x9e\xa1\xf6\x09\xcc\xdc\x63\x66\xa8\x01\xe9\x3b\x0d\xd7\x5a\x85"
1935     + "\xbb\xc5\x65\xc0\x7b\x2e\x46\xa9\xd9\x56\x1d\x4c\x92\x72\x26\x4e"
1936     + "\x86\xd5\x68\xae\xc4\xaa\x55\xce\xd7\x83\x59\xb3\x81\xee\xce\x74"
1937     + "\x39\x39\x31\x9f\x8a\x25\xe8\xa5\xa5\xe5\x81\xf2\x11\x23\xcb\xa1"
1938     + "\x1e\x43\x12\xe3\xb1\x2a\x2b\xcd\xc8\x8d\x25\x96\xa4\x47\x7d\x95"
1939     + "\xa5\xc6\x9f\x61\xe4\x25\xc6\x5e\x69\xc4\xe7\x29\x5b\x6e\xb6\xa4"
1940     + "\xad\x0b\x4e\x72\x95\x25\x58\x56\x33\x9c\x67\xce\xef\x0f\x17\xbf"
1941     + "\x4c\x7b\x2d\xe6\xfe\x76\x35\x27\x5a\x07\x97\x67\xe8\xae\x8d\x71"
1942     + "\x0f\xb2\x13\x99\xb9\xbc\x14\xad\xb3\xb7\xe6\x11\x6f\xe0\xda\x58"
1943     + "\xb1\x08\xac\xa6\x6c\x2d\x7f\x05\xb7\x56\xd2\xe6\xcf\xbb\x4d\x0c"
1944     + "\xe3\x50\xb2\xec\x91\xf0\x4a\xb8\xd6\x22\xb8\xa7\xf6\x67\xaf\xcf"
1945     + "\x63\x7e\xd7\xe7\x42\xd8\xbd\xc3\x71\xa1\xf2\x7e\x9b\xa8\x97\x83"
1946     + "\x6e\xd1\xdc\x4b\x06\x11\x2d\xae\x26\x61\x98\x72\x10\xf4\x42\x5d"
1947     + "\x20\x4a\xa3\x73\xd7\xf2\xcd\x3c\x48\x32\xe4\x03\x9f\x80\x37\x08"
1948     + "\x36\x11\xd0\xcb\x97\x6c\x08\xed\x6d\x33\x24\xa2\x1b\xb4\x77\xdf"
1949     + "\x61\x5d\x5f\xc1\x43\xc2\x82\xeb\x0f\x5d\x84\x08\x68\xaa\xa4\x01"
1950     + "\xe1\x19\xdf\xbc\x31\x65\xfe\xd1\xf5\x7d\x7a\xb2\x2a\x33\x50\x21"
1951     + "\x2a\x56\x9d\xb1\x81\xab\xdb\x35\x78\x30\x83\xd9\x89\x1d\x31\xac"
1952     + "\x96\x14\x07\x61\xbc\x20\x68\x42\x85\x33\x19\xac\xbe\xdb\x34\x56"
1953     + "\xf1\xd5\xfd\x29\xa9\x28\xdb\xcb\x4c\x5a\x23\xdc\xf5\x96\xc5\x10"
1954     + "\xa3\x35\x5b\x14\x68\xd3\x61\x62\x64\x76\x26\xcb\x17\x3e\x34\x98"
1955     + "\x04\xa3\xc4\x20\x38\x90\x92\xe3\xc8\x07\x2c\x36\x74\x66\x26\x0e"
1956     + "\x29\x02\x64\x29\x2d\x21\xe6\x16\x9c\x6b\xce\xa3\x89\xd9\x4f\xd3"
1957     + "\xc4\xbd\xc5\x87\x79\x9c\x65\xf6\x39\x45\x60\xe8\xce\x9e\xab\x6d"
1958     + "\x13\x15\x22\xe1\x5e\x4b\x38\x42\xc4\x1e\xd5\x76\xe0\xc5\xeb\x85"
1959     + "\x07\x2d\x0f\xb8\xb6\xa6\xd6\x6d\x71\x0d\xa2\x43\x4c\x25\xea\xfa"
1960     + "\xa1\xae\x4c\xe4\x7d\xbd\x76\xa9\xfb\x06\xc2\x83\x42\xeb\xad\xe7"
1961     + "\xe9\x5f\x68\x6f\xba\xfb\x2f\x07\xce\xb8\x13\xc1\x9b\xeb\xb0\x76"
1962     + "\x45\x57\x28\x7b\xea\xbe\x0f\xf4\x30\x7b\xa0\xed\xe4\x22\x93\x21"
1963     + "\xfc\xbc\xe0\xb9\x75\xc1\x4f\xfc\xef\xb6\xfa\xa1\xfc\x64\xa1\x4a"
1964     + "\x82\xc7\x33\xad\x75\xed\x82\xbd\x3d\xdb\xf7\xa8\xbe\x5e\xbb\x36"
1965     + "\x62\x04\x9a\x2e\xc5\xd9\x9e\x9c\x3a\x0b\x98\x0b\x57\xac\xf1\x24"
1966     + "\x62\x58\x83\x15\x5b\xa6\xf2\xda\x34\x70\x03\xce\x0f\x93\x1b\x12"
1967     + "\xc7\xce\x54\x87\x33\x15\xd6\x53\x25\x1f\x2a\x90\x87\x12\xe3\x78"
1968     + "\xef\x55\x77\x4d\x4a\xd8\x7e\xef\xd2\xfd\xd1\xaf\x3a\xaf\x55\xdb"
1969     + "\x6a\x2d\x3d\x42\xac\x51\x79\xee\x91\xab\xe1\x05\x2d\x3c\x80\xa2"
1970     + "\x43\xad\x22\x2e\xd5\x33\x13\xa4\x9e\x00\xe0\x04\x10\x84\xc8\xf2"
1971     + "\x19\x30\x92\x1f\xaa\xc3\x28\xc9\x76\x30\x3f\xe9\x10\x61\x5e\x79"
1972     + "\xd5\xf7\xdf\xd0\x54\xdb\xae\xb6\xae\xfa\xe8\xa3\x57\xe0\x6c\x2d"
1973     + "\xf7\xbd\x49\xd6\x6e\x76\x79\xcc\x54\x0c\x5f\xff\x00\xbb\x06\x98"
1974     + "\xa6\x9e\x89\x61\xb4\x6f\xc3\xe3\x6a\xc2\x4f\x59\x03\xc9\x80\x2c"
1975     + "\x59\x24\x44\x70\x38\xd5\x96\x6a\x9e\x8b\x81\x64\xe5\xbc\xa0\x3c"
1976     + "\x33\xaf\x17\x9d\xff\x00\x71\x1a\xd1\x3a\x80\x66\xb3\xd9\x31\x77"
1977     + "\x0d\x12\xbd\xae\x29\xb5\x6a\xd6\xcf\x8d\x68\x87\x75\xcd\xe8\x65"
1978     + "\x5a\xbe\x3c\x04\x7b\x34\xdb\x54\x19\xa4\x63\x9c\x2a\x5d\x23\xbe"
1979     + "\xf4\xb1\x1c\x4d\x90\xec\x92\x2f\x49\x71\xf7\x14\xf2\x97\x9f\x15"
1980     + "\x57\xed\x13\x21\x2a\xf5\x33\xd1\x2a\x52\x52\xac\xb7\x62\xd1\xcb"
1981     + "\x46\x73\x8c\x67\x28\x56\x77\x86\xbf\x6f\x2a\x4e\x73\xfe\x95\x65"
1982     + "\x0b\x5a\x3e\x38\xfc\xfc\xaa\x56\x3f\x86\x73\xe3\xb9\x4a\x52\x84"
1983     + "\xa5\x08\x4e\x12\x94\x27\x09\x4a\x53\x8c\x61\x29\x4a\x71\xf0\x4a"
1984     + "\x53\x8c\x7e\x31\x8c\x63\x18\xc6\x31\x8f\xc6\x31\xf8\xc7\x9f\x7c"
1985     + "\xd5\xbb\xae\x5e\xe2\x1f\xab\x6e\x24\x34\x00\x8a\x25\x83\x70\x40"
1986     + "\x1c\xcc\xda\x45\x7f\x66\x4e\x30\x2e\x94\x7e\x74\x49\xf0\xe4\x4e"
1987     + "\x06\x5c\xa8\x2f\x89\x21\x2e\x98\x0e\xd9\x21\xc2\x0b\x21\x0f\xc4"
1988     + "\x16\x6e\x48\xd9\xe4\xe3\x4a\x19\x1e\x64\x67\x54\xff\x00\x3a\x6d"
1989     + "\x4f\x62\xb5\x00\x4a\xaa\x51\xfd\x2d\xe8\x0e\x6c\xaf\xc6\x7d\x6d"
1990     + "\xc8\x88\xc7\x67\xea\x8a\x58\x02\x73\xe3\x65\x4d\xc9\x24\xc0\x3d"
1991     + "\x57\xa3\x2e\x53\x16\x99\x4f\xe5\xe7\x19\x97\x3e\x3b\xcf\xc9\x4b"
1992     + "\x99\x7f\x33\x25\xa5\xdf\xba\x77\x2b\xd3\x3e\xc2\x7b\x8b\x94\x07"
1993     + "\xe9\x52\x5b\x43\x87\x34\x14\x86\x37\xcf\x41\x6b\x8e\x6a\xa5\x22"
1994     + "\xab\xdb\x96\xa2\xcf\x46\xd8\x9b\x45\x93\xef\xd6\xdf\x3e\x99\x9c"
1995     + "\x7e\x29\x10\x6b\x6c\xa2\xb8\x43\x05\x09\x44\x70\x8c\xb8\xaa\x54"
1996     + "\x7c\x30\x36\x5e\x1c\x5e\x5b\x9f\x6c\x0d\x81\xee\xa0\x93\x8d\x67"
1997     + "\x55\xf3\x87\xaf\xaa\x6b\x58\xf9\xbe\xb2\x36\x07\x42\x6e\xbd\x96"
1998     + "\xe3\x9f\x1f\x8f\xc9\xf4\x9d\xae\x6a\x7d\x4c\x96\xbe\x5f\xc7\xcd"
1999     + "\xf3\xb2\xf7\xcd\xf0\xcf\xc3\xe4\xf8\xfe\x37\x4f\x1c\x4d\xf6\x40"
2000     + "\xf1\x6b\x7c\x4e\xe0\xa6\x71\xad\x56\xa7\x1c\x5c\x15\x6b\xfc\xf3"
2001     + "\x01\x5d\xac\xf1\x75\x9a\x72\x6b\xaa\x28\xc5\x88\x6d\xfb\x33\x85"
2002     + "\xe0\x4e\x61\xab\xeb\x31\x2c\x71\x08\x73\x11\x3b\xfc\xb5\xc0\x96"
2003     + "\xcc\x87\x24\x44\xb5\x9b\x9e\xb3\x71\xba\xe9\xed\xb1\x4e\xd7\x76"
2004     + "\x6c\xd2\xb6\x05\xb7\x5a\xde\xeb\x34\x5b\x96\x16\xfb\x59\xa9\x5c"
2005     + "\x4f\x55\xca\x8a\xac\x59\xb0\xe4\x54\x39\x25\xbc\x81\x37\x2a\x09"
2006     + "\x5f\x9e\x3b\x6b\x7d\x1f\x69\xf3\x34\x85\x39\x84\xa7\x28\x0b\xd3"
2007     + "\xfd\xfb\x4b\x7a\xea\xe7\xd2\x3c\xd3\xda\x15\x68\xbc\x73\xd3\x22"
2008     + "\x6f\xd7\x72\x5b\x2b\x66\xee\xa8\x0d\x54\xe8\x5b\xf9\x92\x96\x92"
2009     + "\x93\xea\x97\x4a\xc7\x43\x10\x46\x35\xc5\xc0\x60\x8a\xe4\xc1\xb5"
2010     + "\x36\xc6\xae\xed\xf7\x70\xa5\x86\x99\x3d\x91\xf8\xfd\x4e\x53\xeb"
2011     + "\xbb\xbd\x6d\xec\x8f\xd7\x89\x3d\x31\x7f\xd7\x78\xba\x50\xbb\x74"
2012     + "\x9d\xf6\xac\x4e\xb9\x03\x9c\x79\xd5\xe1\xbd\x17\x68\xd9\x13\x0b"
2013     + "\x45\x75\x88\x00\x1d\x1f\xae\x73\x6a\x1d\x5c\x6e\x44\x9f\xa6\xfa"
2014     + "\x4e\xd8\x25\x8b\xc0\xbc\xb2\x99\xe3\x17\x24\xb3\x23\xe2\x48\x8b"
2015     + "\xfa\x22\xe7\x7e\x8f\xe6\x3f\x5f\x55\x0d\x75\xd3\x51\x0b\xd7\xed"
2016     + "\xd3\x6f\x97\x3b\x85\x42\x80\x7e\x5f\xdc\x1b\xd6\xba\xee\xc4\x80"
2017     + "\xce\x06\xa9\x15\x8c\x97\x5f\x40\x69\xb2\x4d\xc5\xb2\x5c\x1e\x01"
2018     + "\x87\x7e\xe0\x36\x6d\x78\x80\x4e\x3c\x02\xec\x90\x1d\x11\x81\x74"
2019     + "\xa5\x8b\xa4\xa0\x56\x06\xd5\x79\x72\x85\x57\x3b\xb2\x2e\xae\x90"
2020     + "\x18\x8d\x91\xb2\x0e\x44\x19\xaa\xb4\xcc\x08\xed\x46\xfa\xd7\x2b"
2021     + "\x78\x58\x72\x5d\xbb\x5e\x49\xe7\xee\xf3\x8a\x9d\x22\xa4\x19\xc8"
2022     + "\xe7\x08\xc3\x90\x9b\x35\x9a\xa4\x25\x8c\x4b\x9b\xa7\xf8\xbf\x81"
2023     + "\xf5\xdf\x22\x66\xf1\x7e\x9f\x66\x3d\xbb\xfa\x73\x73\x4d\xfd\x67"
2024     + "\x7b\xf4\xce\xc3\x62\x2e\x6f\xbb\x0c\xa2\xdc\x69\xfc\x8a\x17\x0e"
2025     + "\x3a\x9e\x83\x46\xd7\xe3\x5e\x65\x86\xc0\x51\x00\xbb\x91\xe3\xe1"
2026     + "\xc1\x16\xc4\xe9\x65\x5c\x14\x3e\x44\x6a\x6b\xd1\x1e\xb0\x36\xdd"
2027     + "\x0b\x7d\x8a\xeb\xaf\x58\x5b\x64\x3f\x38\xed\x52\x76\xe8\x46\xf7"
2028     + "\x86\x84\xb3\x93\xb1\x0b\xe5\xfd\xfd\x0d\xe9\x6d\xe4\xf1\x1b\x1d"
2029     + "\x56\xb4\x34\xe4\x6a\xf5\xa4\x9c\x2c\xc9\x64\x94\xc1\xf5\x79\x6d"
2030     + "\x12\x96\xf3\x47\xc5\x48\xa8\xdb\xd8\x95\x64\x29\xcf\xf6\x88\xf1"
2031     + "\x95\x7a\x98\xe8\xbc\x27\x19\xce\x73\x61\xd1\xb8\xc6\x31\x8c\xe7"
2032     + "\x39\xce\x77\x9e\xbc\xc6\x31\x8c\x63\xf3\x9c\xe7\x39\xc6\x31\x8f"
2033     + "\xf7\xce\x7e\x1e\x3b\x7f\x0f\x0f\x0f\x13\x57\xb9\x0a\xe1\x0b\x64"
2034     + "\x5f\x58\x40\xc6\xc7\x7a\x4b\xf2\x3d\xbc\x71\xf4\xa7\xd2\xca\x14"
2035     + "\xe2\x98\x1a\x30\x1e\xe0\x26\x5a\x6a\xf0\x9c\x67\x38\x66\x00\xb8"
2036     + "\x72\xe6\xbe\xac\xfe\x12\xd3\x0b\x56\x73\x8c\x63\xc7\x2b\xe1\xe2"
2037     + "\xe8\xdd\x7b\xff\x00\xd8\xe5\x23\x6c\xce\xa8\x69\xcf\x5e\x3a\xef"
2038     + "\x77\xea\xe5\xab\x0e\x82\xdb\xd9\xed\x7a\x9e\xb8\x6d\x51\x32\xdb"
2039     + "\x79\xc3\x36\x9a\x2d\xa3\x50\x39\x65\x0a\x63\x0e\xe5\xd4\x39\x12"
2040     + "\xbf\x8b\x98\xa4\xa1\x2d\xad\xb3\xcf\x65\x6a\x43\x78\xb3\x3b\x07"
2041     + "\xd8\xd5\xea\xae\x76\xad\x6f\xf5\xff\x00\xca\x93\xab\x96\xb0\x64"
2042     + "\xeb\xd6\x4a\xd5\x87\xba\xec\x24\x60\x97\x06\x76\x03\xe3\x4c\x07"
2043     + "\x29\x11\x8e\x34\x25\x02\x64\x29\xf0\x25\x48\x85\x3a\x33\x8b\x7a"
2044     + "\x3c\x86\x1e\x75\xa5\x61\xc6\x97\x9f\x8d\x25\xf5\xc9\xcd\xde\xc9"
2045     + "\x7d\x77\xf2\xc8\x7e\x70\xaf\x73\x5f\x2d\xec\xa2\x51\x2d\x96\xfb"
2046     + "\x89\xad\x80\x57\xb2\x36\x1d\x7d\x83\x45\xac\xf3\xdb\xcc\x6c\x31"
2047     + "\x4f\xcf\x30\x58\xd0\x12\x28\x90\x50\x42\x86\xfb\x48\x16\x3c\xc5"
2048     + "\x9c\xf8\xe7\xcc\x29\x88\xb3\x4a\x4b\x4e\x6c\xbc\xdb\xc7\xbb\xe9"
2049     + "\xb6\xa0\x8b\x11\xa1\x7d\x73\xd7\xe9\xbf\x7e\xc2\x6c\x10\x8d\xee"
2050     + "\x9d\xef\x63\x3a\xe0\xf5\xbe\x8c\x3e\xa1\xc7\xc5\xd1\x00\x44\x1e"
2051     + "\xf3\x51\xf2\xe2\xb0\xe3\xb5\x13\x7f\x32\xf1\x8c\xa6\x22\xfe\x1f"
2052     + "\x49\x4d\xbb\xcf\x3a\x5d\xed\x4c\xd2\xfc\x85\xed\x23\xd6\xc7\x50"
2053     + "\xb6\x5b\x3a\x16\x83\xb8\x6f\xfd\x32\x3f\xaa\x36\x34\xbb\xf5\x96"
2054     + "\xa9\xab\xcf\x9f\x8f\xac\xc3\xca\xd5\x8b\xd8\x48\x9e\x79\xaa\x30"
2055     + "\x87\xca\x58\x4d\x59\x96\xb9\x4f\xc5\x1b\x1c\xd2\xda\x5b\xe6\x57"
2056     + "\x29\xa1\x28\x7a\x2b\x5b\xff\x00\x12\x2f\x5e\x3f\xf3\xbb\x8e\x7f"
2057     + "\xec\xc6\x98\xff\x00\xed\x3c\xa6\xdd\xa9\xdc\x7e\xa0\xf7\xd6\x99"
2058     + "\x31\xa2\xf7\xaf\x6b\xe9\x82\x74\x4b\x3d\x8f\x5e\x58\x0b\x33\xab"
2059     + "\xef\xc3\xaf\x84\x64\xb9\xae\xb6\x25\x5f\x62\x8f\x1c\xe3\xf4\x51"
2060     + "\xb7\x96\xe3\x0e\x30\x42\xa9\x18\x39\xbf\x9e\x2a\x1f\x74\x19\x02"
2061     + "\x2d\x43\x93\x06\x63\xb1\xa7\x47\x6a\xfa\x9b\x6c\xeb\xbd\xe9\xae"
2062     + "\x6a\x7b\x6f\x53\x5a\x60\x5d\xb5\xcd\xe8\x67\xeb\x35\x3b\x48\xc6"
2063     + "\xa6\xb3\x04\xc8\xdf\xb8\x7e\x26\x64\xb0\xc9\x18\xb0\xa7\x33\xf2"
2064     + "\x4a\x8b\x22\x3b\x8d\x4b\x89\x1d\xf6\x9d\x65\xc4\x38\xd2\x54\x9c"
2065     + "\xe3\xcd\x89\xe1\xe1\xe6\x3e\x70\x81\x45\x1d\x18\xf9\x31\x83\xc8"
2066     + "\xbe\x14\x82\x4b\x87\x7a\x74\x28\xd2\xdd\x12\x55\x30\xe6\x0e\x49"
2067     + "\x31\x8e\x48\x69\xc5\xc0\x20\x91\xe4\x48\x41\x4c\xd8\xb9\x6a\x4e"
2068     + "\x21\xce\x99\x1b\x0e\xfd\x09\x4f\xa1\x79\x0f\x0f\x0f\x0f\x0f\x0f"
2069     + "\x0f\x3f\x3c\xb8\x71\x27\xc7\x72\x24\xe8\xb1\xa6\xc5\x7b\x18\xc3"
2070     + "\xb1\xa5\xb0\xd4\x98\xee\xe3\x19\xc6\x71\x87\x19\x79\x2b\x6d\x78"
2071     + "\xc6\x71\x8c\xe3\x0a\x4e\x71\x8c\xe3\x19\xfe\x38\xf2\x3b\xfb\x8b"
2072     + "\x48\xfe\x4e\xaa\xff\x00\x4f\x08\xff\x00\xc7\xe1\xfb\x8b\x48\xfe"
2073     + "\x4e\xaa\xff\x00\x4f\x08\xff\x00\xc7\xe4\x95\x86\x18\x8a\xcb\x31"
2074     + "\xa3\x32\xd4\x78\xf1\xdb\x43\x2c\x47\x61\xb4\x32\xcb\x2c\xb4\x9c"
2075     + "\x21\xb6\x99\x69\xbc\x25\xb6\xdb\x6d\x18\xc2\x10\xda\x12\x94\xa1"
2076     + "\x38\xc2\x53\x8c\x63\x18\xc7\x9d\xbe\x7f\xff\xd9"
2077     + ;
2078     diff -Nura php-5.2.6/main/suhosin_patch.c suhosin-patch-5.2.6/main/suhosin_patch.c
2079     --- php-5.2.6/main/suhosin_patch.c 1970-01-01 01:00:00.000000000 +0100
2080     +++ suhosin-patch-5.2.6/main/suhosin_patch.c 2008-05-01 11:54:41.000000000 +0200
2081     @@ -0,0 +1,380 @@
2082     +/*
2083     + +----------------------------------------------------------------------+
2084     + | Suhosin Patch for PHP |
2085     + +----------------------------------------------------------------------+
2086     + | Copyright (c) 2004-2006 Stefan Esser |
2087     + +----------------------------------------------------------------------+
2088     + | This source file is subject to version 2.02 of the PHP license, |
2089     + | that is bundled with this package in the file LICENSE, and is |
2090     + | available at through the world-wide-web at |
2091     + | http://www.php.net/license/2_02.txt. |
2092     + | If you did not receive a copy of the PHP license and are unable to |
2093     + | obtain it through the world-wide-web, please send a note to |
2094     + | license@php.net so we can mail you a copy immediately. |
2095     + +----------------------------------------------------------------------+
2096     + | Author: Stefan Esser <sesser@hardened-php.net> |
2097     + +----------------------------------------------------------------------+
2098     + */
2099     +/* $Id: php5-5.2.6-suhosin-0.9.6.2.patch,v 1.1 2008-08-17 17:36:49 niro Exp $ */
2100     +
2101     +#include "php.h"
2102     +
2103     +#include <stdio.h>
2104     +#include <stdlib.h>
2105     +
2106     +#if HAVE_UNISTD_H
2107     +#include <unistd.h>
2108     +#endif
2109     +#include "SAPI.h"
2110     +#include "php_globals.h"
2111     +
2112     +#if SUHOSIN_PATCH
2113     +
2114     +#ifdef HAVE_SYS_SOCKET_H
2115     +#include <sys/socket.h>
2116     +#endif
2117     +
2118     +#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
2119     +#undef AF_UNIX
2120     +#endif
2121     +
2122     +#if defined(AF_UNIX)
2123     +#include <sys/un.h>
2124     +#endif
2125     +
2126     +#define SYSLOG_PATH "/dev/log"
2127     +
2128     +#ifdef PHP_WIN32
2129     +static HANDLE log_source = 0;
2130     +#endif
2131     +
2132     +#include "snprintf.h"
2133     +
2134     +#include "suhosin_patch.h"
2135     +
2136     +#ifdef ZTS
2137     +#include "suhosin_globals.h"
2138     +int suhosin_patch_globals_id;
2139     +#else
2140     +struct _suhosin_patch_globals suhosin_patch_globals;
2141     +#endif
2142     +
2143     +static void php_security_log(int loglevel, char *fmt, ...);
2144     +
2145     +static void suhosin_patch_globals_ctor(suhosin_patch_globals_struct *suhosin_patch_globals TSRMLS_DC)
2146     +{
2147     + memset(suhosin_patch_globals, 0, sizeof(*suhosin_patch_globals));
2148     +}
2149     +
2150     +PHPAPI void suhosin_startup()
2151     +{
2152     +#ifdef ZTS
2153     + ts_allocate_id(&suhosin_patch_globals_id, sizeof(suhosin_patch_globals_struct), (ts_allocate_ctor) suhosin_patch_globals_ctor, NULL);
2154     +#else
2155     + suhosin_patch_globals_ctor(&suhosin_patch_globals TSRMLS_CC);
2156     +#endif
2157     + zend_suhosin_log = php_security_log;
2158     +}
2159     +
2160     +/*PHPAPI void suhosin_clear_mm_canaries(TSRMLS_D)
2161     +{
2162     + zend_alloc_clear_mm_canaries(AG(heap));
2163     + SPG(canary_1) = zend_canary();
2164     + SPG(canary_2) = zend_canary();
2165     + SPG(canary_3) = zend_canary();
2166     +}*/
2167     +
2168     +static char *loglevel2string(int loglevel)
2169     +{
2170     + switch (loglevel) {
2171     + case S_FILES:
2172     + return "FILES";
2173     + case S_INCLUDE:
2174     + return "INCLUDE";
2175     + case S_MEMORY:
2176     + return "MEMORY";
2177     + case S_MISC:
2178     + return "MISC";
2179     + case S_SESSION:
2180     + return "SESSION";
2181     + case S_SQL:
2182     + return "SQL";
2183     + case S_EXECUTOR:
2184     + return "EXECUTOR";
2185     + case S_VARS:
2186     + return "VARS";
2187     + default:
2188     + return "UNKNOWN";
2189     + }
2190     +}
2191     +
2192     +static void php_security_log(int loglevel, char *fmt, ...)
2193     +{
2194     + int s, r, i=0;
2195     +#if defined(AF_UNIX)
2196     + struct sockaddr_un saun;
2197     +#endif
2198     +#ifdef PHP_WIN32
2199     + LPTSTR strs[2];
2200     + unsigned short etype;
2201     + DWORD evid;
2202     +#endif
2203     + char buf[4096+64];
2204     + char error[4096+100];
2205     + char *ip_address;
2206     + char *fname;
2207     + char *alertstring;
2208     + int lineno;
2209     + va_list ap;
2210     + TSRMLS_FETCH();
2211     +
2212     + /*SDEBUG("(suhosin_log) loglevel: %d log_syslog: %u - log_sapi: %u - log_script: %u", loglevel, SPG(log_syslog), SPG(log_sapi), SPG(log_script));*/
2213     +
2214     + if (SPG(log_use_x_forwarded_for)) {
2215     + ip_address = sapi_getenv("HTTP_X_FORWARDED_FOR", 20 TSRMLS_CC);
2216     + if (ip_address == NULL) {
2217     + ip_address = "X-FORWARDED-FOR not set";
2218     + }
2219     + } else {
2220     + ip_address = sapi_getenv("REMOTE_ADDR", 11 TSRMLS_CC);
2221     + if (ip_address == NULL) {
2222     + ip_address = "REMOTE_ADDR not set";
2223     + }
2224     + }
2225     +
2226     +
2227     + va_start(ap, fmt);
2228     + ap_php_vsnprintf(error, sizeof(error), fmt, ap);
2229     + va_end(ap);
2230     + while (error[i]) {
2231     + if (error[i] < 32) error[i] = '.';
2232     + i++;
2233     + }
2234     +
2235     +/* if (SPG(simulation)) {
2236     + alertstring = "ALERT-SIMULATION";
2237     + } else { */
2238     + alertstring = "ALERT";
2239     +/* }*/
2240     +
2241     + if (zend_is_executing(TSRMLS_C)) {
2242     + if (EG(current_execute_data)) {
2243     + lineno = EG(current_execute_data)->opline->lineno;
2244     + fname = EG(current_execute_data)->op_array->filename;
2245     + } else {
2246     + lineno = zend_get_executed_lineno(TSRMLS_C);
2247     + fname = zend_get_executed_filename(TSRMLS_C);
2248     + }
2249     + ap_php_snprintf(buf, sizeof(buf), "%s - %s (attacker '%s', file '%s', line %u)", alertstring, error, ip_address, fname, lineno);
2250     + } else {
2251     + fname = sapi_getenv("SCRIPT_FILENAME", 15 TSRMLS_CC);
2252     + if (fname==NULL) {
2253     + fname = "unknown";
2254     + }
2255     + ap_php_snprintf(buf, sizeof(buf), "%s - %s (attacker '%s', file '%s')", alertstring, error, ip_address, fname);
2256     + }
2257     +
2258     + /* Syslog-Logging disabled? */
2259     + if (((SPG(log_syslog)|S_INTERNAL) & loglevel)==0) {
2260     + goto log_sapi;
2261     + }
2262     +
2263     +#if defined(AF_UNIX)
2264     + ap_php_snprintf(error, sizeof(error), "<%u>suhosin[%u]: %s\n", (unsigned int)(SPG(log_syslog_facility)|SPG(log_syslog_priority)),getpid(),buf);
2265     +
2266     + s = socket(AF_UNIX, SOCK_DGRAM, 0);
2267     + if (s == -1) {
2268     + goto log_sapi;
2269     + }
2270     +
2271     + memset(&saun, 0, sizeof(saun));
2272     + saun.sun_family = AF_UNIX;
2273     + strcpy(saun.sun_path, SYSLOG_PATH);
2274     + /*saun.sun_len = sizeof(saun);*/
2275     +
2276     + r = connect(s, (struct sockaddr *)&saun, sizeof(saun));
2277     + if (r) {
2278     + close(s);
2279     + s = socket(AF_UNIX, SOCK_STREAM, 0);
2280     + if (s == -1) {
2281     + goto log_sapi;
2282     + }
2283     +
2284     + memset(&saun, 0, sizeof(saun));
2285     + saun.sun_family = AF_UNIX;
2286     + strcpy(saun.sun_path, SYSLOG_PATH);
2287     + /*saun.sun_len = sizeof(saun);*/
2288     +
2289     + r = connect(s, (struct sockaddr *)&saun, sizeof(saun));
2290     + if (r) {
2291     + close(s);
2292     + goto log_sapi;
2293     + }
2294     + }
2295     + send(s, error, strlen(error), 0);
2296     +
2297     + close(s);
2298     +#endif
2299     +#ifdef PHP_WIN32
2300     + ap_php_snprintf(error, sizeof(error), "suhosin[%u]: %s", getpid(),buf);
2301     +
2302     + switch (SPG(log_syslog_priority)) { /* translate UNIX type into NT type */
2303     + case 1: /*LOG_ALERT:*/
2304     + etype = EVENTLOG_ERROR_TYPE;
2305     + break;
2306     + case 6: /*LOG_INFO:*/
2307     + etype = EVENTLOG_INFORMATION_TYPE;
2308     + break;
2309     + default:
2310     + etype = EVENTLOG_WARNING_TYPE;
2311     + }
2312     + evid = loglevel;
2313     + strs[0] = error;
2314     + /* report the event */
2315     + if (log_source == NULL) {
2316     + log_source = RegisterEventSource(NULL, "Suhosin-Patch-" SUHOSIN_PATCH_VERSION);
2317     + }
2318     + ReportEvent(log_source, etype, (unsigned short) SPG(log_syslog_priority), evid, NULL, 1, 0, strs, NULL);
2319     +
2320     +#endif
2321     +log_sapi:
2322     + /* SAPI Logging activated? */
2323     + /*SDEBUG("(suhosin_log) log_syslog: %u - log_sapi: %u - log_script: %u - log_phpscript: %u", SPG(log_syslog), SPG(log_sapi), SPG(log_script), SPG(log_phpscript));*/
2324     + if (((SPG(log_sapi)|S_INTERNAL) & loglevel)!=0) {
2325     + sapi_module.log_message(buf);
2326     + }
2327     +
2328     +/*log_script:*/
2329     + /* script logging activaed? */
2330     + if (((SPG(log_script) & loglevel)!=0) && SPG(log_scriptname)!=NULL) {
2331     + char cmd[8192], *cmdpos, *bufpos;
2332     + FILE *in;
2333     + int space;
2334     +
2335     + ap_php_snprintf(cmd, sizeof(cmd), "%s %s \'", SPG(log_scriptname), loglevel2string(loglevel));
2336     + space = sizeof(cmd) - strlen(cmd);
2337     + cmdpos = cmd + strlen(cmd);
2338     + bufpos = buf;
2339     + if (space <= 1) return;
2340     + while (space > 2 && *bufpos) {
2341     + if (*bufpos == '\'') {
2342     + if (space<=5) break;
2343     + *cmdpos++ = '\'';
2344     + *cmdpos++ = '\\';
2345     + *cmdpos++ = '\'';
2346     + *cmdpos++ = '\'';
2347     + bufpos++;
2348     + space-=4;
2349     + } else {
2350     + *cmdpos++ = *bufpos++;
2351     + space--;
2352     + }
2353     + }
2354     + *cmdpos++ = '\'';
2355     + *cmdpos = 0;
2356     +
2357     + if ((in=VCWD_POPEN(cmd, "r"))==NULL) {
2358     + php_security_log(S_INTERNAL, "Unable to execute logging shell script: %s", SPG(log_scriptname));
2359     + return;
2360     + }
2361     + /* read and forget the result */
2362     + while (1) {
2363     + int readbytes = fread(cmd, 1, sizeof(cmd), in);
2364     + if (readbytes<=0) {
2365     + break;
2366     + }
2367     + }
2368     + pclose(in);
2369     + }
2370     +/*log_phpscript:*/
2371     + if ((SPG(log_phpscript) & loglevel)!=0 && EG(in_execution) && SPG(log_phpscriptname) && SPG(log_phpscriptname)[0]) {
2372     + zend_file_handle file_handle;
2373     + zend_op_array *new_op_array;
2374     + zval *result = NULL;
2375     +
2376     + /*long orig_execution_depth = SPG(execution_depth);*/
2377     + zend_bool orig_safe_mode = PG(safe_mode);
2378     + char *orig_basedir = PG(open_basedir);
2379     +
2380     + char *phpscript = SPG(log_phpscriptname);
2381     +/*SDEBUG("scriptname %s", SPG(log_phpscriptname));`*/
2382     +#ifdef ZEND_ENGINE_2
2383     + if (zend_stream_open(phpscript, &file_handle TSRMLS_CC) == SUCCESS) {
2384     +#else
2385     + if (zend_open(phpscript, &file_handle) == SUCCESS && ZEND_IS_VALID_FILE_HANDLE(&file_handle)) {
2386     + file_handle.filename = phpscript;
2387     + file_handle.free_filename = 0;
2388     +#endif
2389     + if (!file_handle.opened_path) {
2390     + file_handle.opened_path = estrndup(phpscript, strlen(phpscript));
2391     + }
2392     + new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC);
2393     + zend_destroy_file_handle(&file_handle TSRMLS_CC);
2394     + if (new_op_array) {
2395     + HashTable *active_symbol_table = EG(active_symbol_table);
2396     + zval *zerror, *zerror_class;
2397     +
2398     + if (active_symbol_table == NULL) {
2399     + active_symbol_table = &EG(symbol_table);
2400     + }
2401     + EG(return_value_ptr_ptr) = &result;
2402     + EG(active_op_array) = new_op_array;
2403     +
2404     + MAKE_STD_ZVAL(zerror);
2405     + MAKE_STD_ZVAL(zerror_class);
2406     + ZVAL_STRING(zerror, buf, 1);
2407     + ZVAL_LONG(zerror_class, loglevel);
2408     +
2409     + zend_hash_update(active_symbol_table, "SUHOSIN_ERROR", sizeof("SUHOSIN_ERROR"), (void **)&zerror, sizeof(zval *), NULL);
2410     + zend_hash_update(active_symbol_table, "SUHOSIN_ERRORCLASS", sizeof("SUHOSIN_ERRORCLASS"), (void **)&zerror_class, sizeof(zval *), NULL);
2411     +
2412     + /*SPG(execution_depth) = 0;*/
2413     + if (SPG(log_phpscript_is_safe)) {
2414     + PG(safe_mode) = 0;
2415     + PG(open_basedir) = NULL;
2416     + }
2417     +
2418     + zend_execute(new_op_array TSRMLS_CC);
2419     +
2420     + /*SPG(execution_depth) = orig_execution_depth;*/
2421     + PG(safe_mode) = orig_safe_mode;
2422     + PG(open_basedir) = orig_basedir;
2423     +
2424     +#ifdef ZEND_ENGINE_2
2425     + destroy_op_array(new_op_array TSRMLS_CC);
2426     +#else
2427     + destroy_op_array(new_op_array);
2428     +#endif
2429     + efree(new_op_array);
2430     +#ifdef ZEND_ENGINE_2
2431     + if (!EG(exception))
2432     +#endif
2433     + {
2434     + if (EG(return_value_ptr_ptr)) {
2435     + zval_ptr_dtor(EG(return_value_ptr_ptr));
2436     + EG(return_value_ptr_ptr) = NULL;
2437     + }
2438     + }
2439     + } else {
2440     + php_security_log(S_INTERNAL, "Unable to execute logging PHP script: %s", SPG(log_phpscriptname));
2441     + return;
2442     + }
2443     + } else {
2444     + php_security_log(S_INTERNAL, "Unable to execute logging PHP script: %s", SPG(log_phpscriptname));
2445     + return;
2446     + }
2447     + }
2448     +
2449     +}
2450     +
2451     +
2452     +#endif
2453     +
2454     +/*
2455     + * Local variables:
2456     + * tab-width: 4
2457     + * c-basic-offset: 4
2458     + * End:
2459     + * vim600: sw=4 ts=4 fdm=marker
2460     + * vim<600: sw=4 ts=4
2461     + */
2462     diff -Nura php-5.2.6/main/suhosin_patch.h suhosin-patch-5.2.6/main/suhosin_patch.h
2463     --- php-5.2.6/main/suhosin_patch.h 1970-01-01 01:00:00.000000000 +0100
2464     +++ suhosin-patch-5.2.6/main/suhosin_patch.h 2008-05-01 11:54:41.000000000 +0200
2465     @@ -0,0 +1,40 @@
2466     +/*
2467     + +----------------------------------------------------------------------+
2468     + | Suhosin Patch for PHP |
2469     + +----------------------------------------------------------------------+
2470     + | Copyright (c) 2004-2006 Stefan Esser |
2471     + +----------------------------------------------------------------------+
2472     + | This source file is subject to version 2.02 of the PHP license, |
2473     + | that is bundled with this package in the file LICENSE, and is |
2474     + | available at through the world-wide-web at |
2475     + | http://www.php.net/license/2_02.txt. |
2476     + | If you did not receive a copy of the PHP license and are unable to |
2477     + | obtain it through the world-wide-web, please send a note to |
2478     + | license@php.net so we can mail you a copy immediately. |
2479     + +----------------------------------------------------------------------+
2480     + | Author: Stefan Esser <sesser@hardened-php.net> |
2481     + +----------------------------------------------------------------------+
2482     + */
2483     +
2484     +#ifndef SUHOSIN_PATCH_H
2485     +#define SUHOSIN_PATCH_H
2486     +
2487     +#if SUHOSIN_PATCH
2488     +
2489     +#include "zend.h"
2490     +
2491     +PHPAPI void suhosin_startup();
2492     +#define SUHOSIN_PATCH_VERSION "0.9.6.2"
2493     +
2494     +#define SUHOSIN_LOGO_GUID "SUHO8567F54-D428-14d2-A769-00DA302A5F18"
2495     +
2496     +#endif
2497     +
2498     +#endif /* SUHOSIN_PATCH_H */
2499     +
2500     +/*
2501     + * Local variables:
2502     + * tab-width: 4
2503     + * c-basic-offset: 4
2504     + * End:
2505     + */
2506     diff -Nura php-5.2.6/main/suhosin_patch.m4 suhosin-patch-5.2.6/main/suhosin_patch.m4
2507     --- php-5.2.6/main/suhosin_patch.m4 1970-01-01 01:00:00.000000000 +0100
2508     +++ suhosin-patch-5.2.6/main/suhosin_patch.m4 2008-05-01 11:54:41.000000000 +0200
2509     @@ -0,0 +1,8 @@
2510     +dnl
2511     +dnl $Id: php5-5.2.6-suhosin-0.9.6.2.patch,v 1.1 2008-08-17 17:36:49 niro Exp $
2512     +dnl
2513     +dnl This file contains Suhosin Patch for PHP specific autoconf functions.
2514     +dnl
2515     +
2516     +AC_DEFINE(SUHOSIN_PATCH, 1, [Suhosin Patch])
2517     +
2518     diff -Nura php-5.2.6/sapi/apache/mod_php5.c suhosin-patch-5.2.6/sapi/apache/mod_php5.c
2519     --- php-5.2.6/sapi/apache/mod_php5.c 2007-12-31 08:20:15.000000000 +0100
2520     +++ suhosin-patch-5.2.6/sapi/apache/mod_php5.c 2008-05-01 11:54:41.000000000 +0200
2521     @@ -951,7 +951,11 @@
2522     {
2523     TSRMLS_FETCH();
2524     if (PG(expose_php)) {
2525     +#if SUHOSIN_PATCH
2526     + ap_add_version_component("PHP/" PHP_VERSION " with Suhosin-Patch");
2527     +#else
2528     ap_add_version_component("PHP/" PHP_VERSION);
2529     +#endif
2530     }
2531     }
2532     #endif
2533     diff -Nura php-5.2.6/sapi/apache2filter/sapi_apache2.c suhosin-patch-5.2.6/sapi/apache2filter/sapi_apache2.c
2534     --- php-5.2.6/sapi/apache2filter/sapi_apache2.c 2007-12-31 08:20:15.000000000 +0100
2535     +++ suhosin-patch-5.2.6/sapi/apache2filter/sapi_apache2.c 2008-05-01 11:54:41.000000000 +0200
2536     @@ -562,7 +562,11 @@
2537     {
2538     TSRMLS_FETCH();
2539     if (PG(expose_php)) {
2540     +#if SUHOSIN_PATCH
2541     + ap_add_version_component(p, "PHP/" PHP_VERSION " with Suhosin-Patch");
2542     +#else
2543     ap_add_version_component(p, "PHP/" PHP_VERSION);
2544     +#endif
2545     }
2546     }
2547    
2548     diff -Nura php-5.2.6/sapi/apache2handler/sapi_apache2.c suhosin-patch-5.2.6/sapi/apache2handler/sapi_apache2.c
2549     --- php-5.2.6/sapi/apache2handler/sapi_apache2.c 2008-01-16 16:50:37.000000000 +0100
2550     +++ suhosin-patch-5.2.6/sapi/apache2handler/sapi_apache2.c 2008-05-01 11:54:41.000000000 +0200
2551     @@ -370,7 +370,11 @@
2552     {
2553     TSRMLS_FETCH();
2554     if (PG(expose_php)) {
2555     +#if SUHOSIN_PATCH
2556     + ap_add_version_component(p, "PHP/" PHP_VERSION " with Suhosin-Patch");
2557     +#else
2558     ap_add_version_component(p, "PHP/" PHP_VERSION);
2559     +#endif
2560     }
2561     }
2562    
2563     diff -Nura php-5.2.6/sapi/cgi/cgi_main.c suhosin-patch-5.2.6/sapi/cgi/cgi_main.c
2564     --- php-5.2.6/sapi/cgi/cgi_main.c 2008-04-09 11:16:40.000000000 +0200
2565     +++ suhosin-patch-5.2.6/sapi/cgi/cgi_main.c 2008-05-01 11:54:41.000000000 +0200
2566     @@ -1726,11 +1726,19 @@
2567     SG(headers_sent) = 1;
2568     SG(request_info).no_headers = 1;
2569     }
2570     +#if SUHOSIN_PATCH
2571     +#if ZEND_DEBUG
2572     + php_printf("PHP %s with Suhosin-Patch %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2008 The PHP Group\n%s", PHP_VERSION, SUHOSIN_PATCH_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
2573     +#else
2574     + php_printf("PHP %s with Suhosin-Patch %s (%s) (built: %s %s)\nCopyright (c) 1997-2008 The PHP Group\n%s", PHP_VERSION, SUHOSIN_PATCH_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
2575     +#endif
2576     +#else
2577     #if ZEND_DEBUG
2578     php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2008 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
2579     #else
2580     php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2008 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
2581     #endif
2582     +#endif
2583     php_request_shutdown((void *) 0);
2584     exit_status = 0;
2585     goto out;
2586     diff -Nura php-5.2.6/sapi/cli/php_cli.c suhosin-patch-5.2.6/sapi/cli/php_cli.c
2587     --- php-5.2.6/sapi/cli/php_cli.c 2008-01-29 21:01:14.000000000 +0100
2588     +++ suhosin-patch-5.2.6/sapi/cli/php_cli.c 2008-05-01 11:54:41.000000000 +0200
2589     @@ -779,8 +779,14 @@
2590     }
2591    
2592     request_started = 1;
2593     - php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2008 The PHP Group\n%s",
2594     - PHP_VERSION, sapi_module.name, __DATE__, __TIME__,
2595     +#if SUHOSIN_PATCH
2596     + php_printf("PHP %s with Suhosin-Patch %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2008 The PHP Group\n%s",
2597     + PHP_VERSION, SUHOSIN_PATCH_VERSION,
2598     +#else
2599     + php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2008 The PHP Group\n%s",
2600     + PHP_VERSION,
2601     +#endif
2602     + sapi_module.name, __DATE__, __TIME__,
2603     #if ZEND_DEBUG && defined(HAVE_GCOV)
2604     "(DEBUG GCOV)",
2605     #elif ZEND_DEBUG
2606     diff -Nura php-5.2.6/win32/build/config.w32 suhosin-patch-5.2.6/win32/build/config.w32
2607     --- php-5.2.6/win32/build/config.w32 2007-04-18 11:38:59.000000000 +0200
2608     +++ suhosin-patch-5.2.6/win32/build/config.w32 2008-05-01 11:54:41.000000000 +0200
2609     @@ -299,7 +299,7 @@
2610     zend_sprintf.c zend_ini.c zend_qsort.c zend_multibyte.c zend_ts_hash.c \
2611     zend_stream.c zend_iterators.c zend_interfaces.c zend_objects.c \
2612     zend_object_handlers.c zend_objects_API.c \
2613     - zend_default_classes.c zend_execute.c zend_strtod.c");
2614     + zend_default_classes.c zend_execute.c zend_strtod.c zend_canary.c");
2615    
2616     ADD_SOURCES("main", "main.c snprintf.c spprintf.c safe_mode.c fopen_wrappers.c \
2617     php_scandir.c php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
2618     @@ -344,6 +344,8 @@
2619     AC_DEFINE('HAVE_USLEEP', 1);
2620     AC_DEFINE('HAVE_STRCOLL', 1);
2621    
2622     +AC_DEFINE('SUHOSIN_PATCH', 1);
2623     +
2624     /* For snapshot builders, where can we find the additional
2625     * files that make up the snapshot template? */
2626     ARG_WITH("snapshot-template", "Path to snapshot builder template dir", "no");