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