Cherrypick from master 2011-08-07 17:42:45 UTC Elan Ruusamäe <glen@pld-linux.org> '- --enable-spl/--disable-spl option does not exist in 5.3+':
bug-52078-fileinode.patch -> 1.5
bug-52448.patch -> 1.1
extension-shared-optional-dep.patch -> 1.1
fix-test-run.patch -> 1.9
mcrypt-libs.patch -> 1.1
mysqlnd-shared.patch -> 1.1
pcre-shared.patch -> 1.3
php-both-apxs.patch -> 1.3
php-branch.sh -> 1.7
php-buff_ovf.patch -> 1.1
php-builddir.patch -> 1.2
php-cgi-fcgi.ini -> 1.4
php-cli.ini -> 1.7
php-config-dir.patch -> 1.3
php-config-file-scan-dir.patch -> 1.4
php-curl-limit-speed.patch -> 1.3
php-dba-link.patch -> 1.2
php-fcgi-error_log-no-newlines.patch -> 1.3
php-fcgi-graceful.patch -> 1.9
php-filter-shared.patch -> 1.1
php-fpm-config.patch -> 1.11
php-fpm-shared.patch -> 1.2
php-fpm.init -> 1.10
php-fpm.logrotate -> 1.4
php-gd_imagerotate_enable.patch -> 1.5
php-imap-annotations.patch -> 1.3
php-imap-myrights.patch -> 1.3
php-include_path.patch -> 1.4
php-ini.patch -> 1.42
php-krb5-ac.patch -> 1.1
php-libpq_fs_h_path.patch -> 1.6
php-libtool.patch -> 1.8
php-link-libs.patch -> 1.11
php-m4-divert.patch -> 1.2
php-mail.patch -> 1.19
php-mod_php.conf -> 1.12
php-mysql-charsetphpini.patch -> 1.5
php-mysql-nowarning.patch -> 1.1
php-mysqli-charsetphpini.patch -> 1.5
php-no_pear_install.patch -> 1.9
php-nohttpd.patch -> 1.2
php-oracle-instantclient.patch -> 1.1
php-pdo_mysql-charsetphpini.patch -> 1.6
php-pear.patch -> 1.5
php-readline.patch -> 1.4
php-sapi-ini-file.patch -> 1.13
php-sh.patch -> 1.1
php-shared.patch -> 1.19
php-silent-session-cleanup.patch -> 1.1
php-stupidapache_version.patch -> 1.4
php-systzdata.patch -> 1.1
php-tds.patch -> 1.4
php-uint32_t.patch -> 1.3
php-use-prog_sendmail.patch -> 1.1
php-zlib-for-getimagesize.patch -> 1.1
php.spec -> 1.945
skip-tests.sh -> 1.12
spl-shared.patch -> 1.6
suhosin.patch -> 1.9
Cherrypick from master 2006-11-02 22:33:32 UTC Elan Ruusamäe <glen@pld-linux.org> '- updated to 5.2.0':
php-threads-acfix.patch -> 1.4
--- /dev/null
+--- php-5.2.13/ext/standard/tests/file/fileinode_variation3.phpt~ 2008-11-25 13:33:41.000000000 +0200
++++ php-5.2.13/ext/standard/tests/file/fileinode_variation3.phpt 2010-06-14 00:23:51.340272864 +0300
+@@ -57,15 +57,15 @@
+ --EXPECTF--
+ *** Testing fileinode() with different notations of file names ***
+ - Iteration 1 -
+-int(%d)
++int(%i)
+ - Iteration 2 -
+
+ Warning: fileinode(): stat failed for %s//fileinode_variation3/fileinode_variation3.tmp/ in %s on line %d
+ bool(false)
+ - Iteration 3 -
+-int(%d)
++int(%i)
+ - Iteration 4 -
+-int(%d)
++int(%i)
+ - Iteration 5 -
+
+ Warning: fileinode(): stat failed for %s//fileinode_variation3/*.tmp in %s on line %d
+--- php-5.3.3/ext/standard/tests/file/fileinode_basic.phpt~ 2007-11-05 19:43:21.000000000 +0200
++++ php-5.3.3/ext/standard/tests/file/fileinode_basic.phpt 2010-07-26 19:31:43.613553760 +0300
+@@ -28,9 +28,9 @@
+ ?>
+ --EXPECTF--
+ *** Testing fileinode() with file, directory ***
+-%d
+-%d
+-%d
+-%d
++%i
++%i
++%i
++%i
+
+ *** Done ***
+--- php-5.3.3/ext/standard/tests/file/fileinode_variation.phpt~ 2007-11-05 19:43:21.000000000 +0200
++++ php-5.3.3/ext/standard/tests/file/fileinode_variation.phpt 2010-07-26 19:34:01.610414378 +0300
+@@ -89,24 +89,24 @@
+ --EXPECTF--
+ *** Testing fileinode() with files, links and directories ***
+ -- Testing with files --
+-%d
+-%d
++%i
++%i
+ -- Testing with links: hard link --
+-%d
+-%d
++%i
++%i
+ -- Testing with links: soft link --
+-%d
+-%d
++%i
++%i
+ -- Testing after copying a file --
+-%d
+-%d
++%i
++%i
+ -- Testing after renaming the file --
+-%d
+-%d
++%i
++%i
+ -- Testing with directories --
+-%d
+-%d
++%i
++%i
+ -- Testing with binary input --
+-%d
+-%d
++%i
++%i
+ *** Done ***
+--- php-5.3.3/ext/standard/tests/file/fileinode_variation1.phpt~ 2008-11-26 12:10:19.000000000 +0200
++++ php-5.3.3/ext/standard/tests/file/fileinode_variation1.phpt 2010-07-26 19:35:31.216291870 +0300
+@@ -42,7 +42,7 @@
+
+ --EXPECTF--
+ *** Testing fileinode() with links ***
+-int(%d)
+-int(%d)
++int(%i)
++int(%i)
+
+ *** Done ***
+--- php-5.3.3/ext/standard/tests/file/filestat.phpt~ 2006-11-15 19:27:03.000000000 +0200
++++ php-5.3.3/ext/standard/tests/file/filestat.phpt 2010-07-26 19:37:10.367060798 +0300
+@@ -30,17 +30,17 @@
+ echo "Done\n";
+ ?>
+ --EXPECTF--
++int(%i)
+ int(%d)
+ int(%d)
+ int(%d)
+ int(%d)
++int(%i)
+ int(%d)
+ int(%d)
+ int(%d)
+ int(%d)
+-int(%d)
+-int(%d)
+-int(%d)
++int(%i)
+ int(%d)
+ int(%d)
+ int(%d)
+--- php-5.3.3/ext/standard/tests/file/lstat_stat_variation18.phpt~ 2010-07-26 19:43:12.000000000 +0300
++++ php-5.3.3/ext/standard/tests/file/lstat_stat_variation18.phpt 2010-07-26 19:43:14.470984630 +0300
+@@ -66,7 +66,7 @@
+ [0]=>
+ int(%d)
+ [1]=>
+- int(%d)
++ int(%i)
+ [2]=>
+ int(%d)
+ [3]=>
+@@ -92,7 +92,7 @@
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+- int(%d)
++ int(%i)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+@@ -122,7 +122,7 @@
+ [0]=>
+ int(%d)
+ [1]=>
+- int(%d)
++ int(%i)
+ [2]=>
+ int(%d)
+ [3]=>
+@@ -148,7 +148,7 @@
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+- int(%d)
++ int(%i)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+--- php-5.3.3/ext/standard/tests/file/lstat_stat_variation19.phpt~ 2007-11-05 19:43:21.000000000 +0200
++++ php-5.3.3/ext/standard/tests/file/lstat_stat_variation19.phpt 2010-07-26 19:44:58.320079730 +0300
+@@ -67,7 +67,7 @@
+ [0]=>
+ int(%d)
+ [1]=>
+- int(%d)
++ int(%i)
+ [2]=>
+ int(%d)
+ [3]=>
+@@ -93,7 +93,7 @@
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+- int(%d)
++ int(%i)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+@@ -121,7 +121,7 @@
+ [0]=>
+ int(%d)
+ [1]=>
+- int(%d)
++ int(%i)
+ [2]=>
+ int(%d)
+ [3]=>
+@@ -147,7 +147,7 @@
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+- int(%d)
++ int(%i)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+@@ -177,7 +177,7 @@
+ [0]=>
+ int(%d)
+ [1]=>
+- int(%d)
++ int(%i)
+ [2]=>
+ int(%d)
+ [3]=>
+@@ -203,7 +203,7 @@
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+- int(%d)
++ int(%i)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+@@ -231,7 +231,7 @@
+ [0]=>
+ int(%d)
+ [1]=>
+- int(%d)
++ int(%i)
+ [2]=>
+ int(%d)
+ [3]=>
+@@ -257,7 +257,7 @@
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+- int(%d)
++ int(%i)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+--- php-5.3.3/ext/standard/tests/file/lstat_stat_variation20.phpt~ 2007-07-26 16:38:24.000000000 +0300
++++ php-5.3.3/ext/standard/tests/file/lstat_stat_variation20.phpt 2010-07-26 19:46:33.907004377 +0300
+@@ -69,7 +69,7 @@
+ [0]=>
+ int(%d)
+ [1]=>
+- int(%d)
++ int(%i)
+ [2]=>
+ int(%d)
+ [3]=>
+@@ -95,7 +95,7 @@
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+- int(%d)
++ int(%i)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+@@ -125,7 +125,7 @@
+ [0]=>
+ int(%d)
+ [1]=>
+- int(%d)
++ int(%i)
+ [2]=>
+ int(%d)
+ [3]=>
+@@ -151,7 +151,7 @@
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+- int(%d)
++ int(%i)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+@@ -179,7 +179,7 @@
+ [0]=>
+ int(%d)
+ [1]=>
+- int(%d)
++ int(%i)
+ [2]=>
+ int(%d)
+ [3]=>
+@@ -205,7 +205,7 @@
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+- int(%d)
++ int(%i)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+@@ -233,7 +233,7 @@
+ [0]=>
+ int(%d)
+ [1]=>
+- int(%d)
++ int(%i)
+ [2]=>
+ int(%d)
+ [3]=>
+@@ -259,7 +259,7 @@
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+- int(%d)
++ int(%i)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+--- php-5.3.3/ext/standard/tests/file/tempnam_variation1.phpt~ 2008-11-26 12:10:19.000000000 +0200
++++ php-5.3.3/ext/standard/tests/file/tempnam_variation1.phpt 2010-07-26 20:24:46.505943227 +0300
+@@ -66,51 +66,51 @@
+ -- Iteration 1 --
+ File name is => %s%etempnam_variation1.tmp%s
+ File permissions are => 100600
+-File inode is => %d
++File inode is => %i
+ File created in => directory specified
+ -- Iteration 2 --
+ File name is => %s%etempnam_variation1.tmp%s
+ File permissions are => 100600
+-File inode is => %d
++File inode is => %i
+ File created in => directory specified
+ -- Iteration 3 --
+ File name is => %s%etempnam_variation1.tmp%s
+ File permissions are => 100600
+-File inode is => %d
++File inode is => %i
+ File created in => directory specified
+ -- Iteration 4 --
+ File name is => %s%etempnam_variation1.tmp%s
+ File permissions are => 100600
+-File inode is => %d
++File inode is => %i
+ File created in => directory specified
+ -- Iteration 5 --
+ File name is => %s%etempnam_variation1.tmp%s
+ File permissions are => 100600
+-File inode is => %d
++File inode is => %i
+ File created in => directory specified
+ -- Iteration 6 --
+ File name is => %s%etempnam_variation1.tmp%s
+ File permissions are => 100600
+-File inode is => %d
++File inode is => %i
+ File created in => directory specified
+ -- Iteration 7 --
+ File name is => %s%etempnam_variation1.tmp%s
+ File permissions are => 100600
+-File inode is => %d
++File inode is => %i
+ File created in => directory specified
+ -- Iteration 8 --
+ File name is => %s%etempnam_variation1.tmp%s
+ File permissions are => 100600
+-File inode is => %d
++File inode is => %i
+ File created in => directory specified
+ -- Iteration 9 --
+ File name is => %s%etempnam_variation1.tmp%s
+ File permissions are => 100600
+-File inode is => %d
++File inode is => %i
+ File created in => directory specified
+ -- Iteration 10 --
+ File name is => %s%etempnam_variation1.tmp%s
+ File permissions are => 100600
+-File inode is => %d
++File inode is => %i
+ File created in => directory specified
+ *** Done ***
+--- php-5.3.3/tests/security/open_basedir_fileinode.phpt~ 2008-05-09 11:39:44.000000000 +0300
++++ php-5.3.3/tests/security/open_basedir_fileinode.phpt 2010-07-27 22:51:29.603089549 +0300
+@@ -46,10 +46,10 @@
+
+ Warning: fileinode(): open_basedir restriction in effect. File(./../.) is not within the allowed path(s): (.) in %s on line %d
+ bool(false)
+-int(%d)
+-int(%d)
+-int(%d)
+-int(%d)
+-int(%d)
++int(%i)
++int(%i)
++int(%i)
++int(%i)
++int(%i)
+ *** Finished testing open_basedir configuration [fileinode] ***
+
+--- php-5.3.3/ext/spl/tests/SplFileInfo_getInode_basic.phpt~ 2010-08-04 16:25:21.000000000 +0300
++++ php-5.3.3/ext/spl/tests/SplFileInfo_getInode_basic.phpt 2010-08-04 16:28:32.722932851 +0300
+@@ -11,6 +11,7 @@
+ --SKIPIF--
+ <?php
+ if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
++if (PHP_INT_SIZE == 4) die("skip this test is for >32bit platform only (inodes overflow there)");
+ ?>
+ --FILE--
+ <?php
--- /dev/null
+--- php-5.3.3/ext/curl/tests/curl_error_basic.phpt~ 2009-07-03 03:09:08.000000000 +0300
++++ php-5.3.3/ext/curl/tests/curl_error_basic.phpt 2010-07-26 21:02:34.822382923 +0300
+@@ -30,4 +30,4 @@
+ ?>
+ --EXPECT--
+ == Testing curl_error with a fake URL ==
+-Error: Couldn't resolve host 'fakeURL'
++Error: Could not resolve host: fakeURL (Domain name not found)
--- /dev/null
+--- php-5.2.11/acinclude.m4~ 2009-09-21 22:31:13.000000000 +0300
++++ php-5.2.11/acinclude.m4 2009-09-21 22:32:11.001106977 +0300
+@@ -1019,7 +1019,7 @@
+ is_it_shared=$[PHP_]translit($2,a-z_-,A-Z__)[_SHARED]
+ is_it_enabled=$[PHP_]translit($2,a-z_-,A-Z__)
+ if test "$am_i_shared" = "no" && test "$is_it_shared" = "yes" ; then
+- AC_MSG_ERROR([
++ AC_MSG_WARN([
+ You've configured extension $1 to build statically, but it
+ depends on extension $2, which you've configured to build shared.
+ You either need to build $1 shared or build $2 statically for the
--- /dev/null
+--- php-5.3.2/configure.in~ 2010-03-16 12:16:56.000000000 +0200
++++ php-5.3.2/configure.in 2010-03-16 16:13:24.926435546 +0200
+@@ -1224,6 +1224,11 @@
+ PHP_SUBST(PHP_CLI_OBJS)
+ PHP_SUBST(PHP_GLOBAL_OBJS)
+
++# shift so that pcre, spl, ... are loaded first
++PHP_MODULES=$(echo "$PHP_MODULES" | sed -e 's,\(.*\)\(\$(phplibdir)/xml.la \),\2\1,')
++PHP_MODULES=$(echo "$PHP_MODULES" | sed -e 's,\(.*\)\(\$(phplibdir)/spl.la \),\2\1,')
++PHP_MODULES=$(echo "$PHP_MODULES" | sed -e 's,\(.*\)\(\$(phplibdir)/pcre.la \),\2\1,')
++
+ PHP_SUBST(PHP_MODULES)
+ PHP_SUBST(PHP_ZEND_EX)
+
+--- php-5.3.4/Makefile.global~ 2010-12-12 23:08:32.000000000 +0200
++++ php-5.3.4/Makefile.global 2010-12-12 23:09:31.246644108 +0200
+@@ -77,7 +77,8 @@
+ done; \
+ fi
+
+-PHP_TEST_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1'
++PHP_TEST_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d 'safe_mode=0'
++PHP_TEST_SHARED_SYSTEM_EXTENSIONS = pcre
+ PHP_TEST_SHARED_EXTENSIONS = ` \
+ if test "x$(PHP_MODULES)" != "x"; then \
+ for i in $(PHP_MODULES)""; do \
+@@ -88,6 +89,12 @@
+ for i in $(PHP_ZEND_EX)""; do \
+ . $$i; $(top_srcdir)/build/shtool echo -n -- " -d $(ZEND_EXT_TYPE)=$(top_builddir)/modules/$$dlname"; \
+ done; \
++ fi; \
++ if test "x$(PHP_TEST_SHARED_SYSTEM_EXTENSIONS)" != "x"; then \
++ for i in $(PHP_TEST_SHARED_SYSTEM_EXTENSIONS)""; do \
++ dlname=$$i.$(SHLIB_DL_SUFFIX_NAME); \
++ $(top_srcdir)/build/shtool echo -n -- " -d extension=$(EXTENSION_DIR)/$$dlname"; \
++ done; \
+ fi`
+ PHP_DEPRECATED_DIRECTIVES_REGEX = '^(define_syslog_variables|register_(globals|long_arrays)?|safe_mode|magic_quotes_(gpc|runtime|sybase)?|(zend_)?extension(_debug)?(_ts)?)[\t\ ]*='
+
+@@ -114,7 +114,10 @@
+ TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
+ TEST_PHP_SRCDIR=$(top_srcdir) \
+ CC="$(CC)" \
+- $(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(TESTS); \
++ $(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini \
++ -d extension_dir=$(top_builddir)/modules/ -d 'extension=$(EXTENSION_DIR)/pcre.$(SHLIB_DL_SUFFIX_NAME)' \
++ $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini \
++ -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(RUN_TESTS_SETTINGS) $(TESTS); \
+ rm $(top_builddir)/tmp-php.ini; \
+ else \
+ echo "ERROR: Cannot run tests without CLI sapi."; \
+--- php-5.3.2/Makefile.global 2010-03-16 16:31:36.972576955 +0200
++++ php-5.3.2/Makefile.global 2010-03-16 16:31:36.972576955 +0200
+@@ -296,7 +296,7 @@
+ fi
+
+ PHP_TEST_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d 'safe_mode=0'
+-PHP_TEST_SHARED_SYSTEM_EXTENSIONS = pcre
++PHP_TEST_SHARED_SYSTEM_EXTENSIONS =
+ PHP_TEST_SHARED_EXTENSIONS = ` \
+ if test "x$(PHP_MODULES)" != "x"; then \
+ for i in $(PHP_MODULES)""; do \
--- /dev/null
+--- php-5.3.6/ext/mcrypt/config.m4~ 2010-01-15 23:02:20.000000000 +0200
++++ php-5.3.6/ext/mcrypt/config.m4 2011-04-09 16:18:07.634572726 +0300
+@@ -36,7 +36,6 @@
+
+ PHP_CHECK_LIBRARY(mcrypt, mcrypt_module_open,
+ [
+- PHP_ADD_LIBRARY(ltdl,, MCRYPT_SHARED_LIBADD)
+ AC_DEFINE(HAVE_LIBMCRYPT,1,[ ])
+ ],[
+ PHP_CHECK_LIBRARY(mcrypt, mcrypt_module_open,
+@@ -48,7 +47,7 @@
+ -L$MCRYPT_DIR/$PHP_LIBDIR
+ ])
+ ],[
+- -L$MCRYPT_DIR/$PHP_LIBDIR -lltdl
++ -L$MCRYPT_DIR/$PHP_LIBDIR
+ ])
+
+ PHP_ADD_LIBRARY_WITH_PATH(mcrypt, $MCRYPT_DIR/$PHP_LIBDIR, MCRYPT_SHARED_LIBADD)
--- /dev/null
+--- php-5.3.2/ext/mysqlnd/config9.m4~ 2009-12-22 21:30:09.000000000 +0200
++++ php-5.3.2/ext/mysqlnd/config9.m4 2010-04-14 01:33:20.435275382 +0300
+@@ -20,7 +20,7 @@
+ mysqlnd_result.c mysqlnd_result_meta.c mysqlnd_debug.c\
+ mysqlnd_block_alloc.c php_mysqlnd.c"
+
+- PHP_NEW_EXTENSION(mysqlnd, $mysqlnd_sources, no)
++ PHP_NEW_EXTENSION(mysqlnd, $mysqlnd_sources, yes)
+ PHP_ADD_BUILD_DIR([ext/mysqlnd], 1)
+ PHP_INSTALL_HEADERS([ext/mysqlnd/])
+
+--- php-5.3.2/ext/mysqlnd/php_mysqlnd.c~ 2010-01-20 19:09:28.000000000 +0200
++++ php-5.3.2/ext/mysqlnd/php_mysqlnd.c 2010-04-14 09:18:30.725599897 +0300
+@@ -273,6 +273,9 @@
+ };
+ /* }}} */
+
++#ifdef COMPILE_DL_MYSQLND
++ZEND_GET_MODULE(mysqlnd)
++#endif
+
+ /*
+ * Local variables:
--- /dev/null
+--- php-5.3.1/ext/pcre/config0.m4 2009-11-27 08:19:08.836025192 +0000
++++ php-5.3.1/ext/pcre/config0.m4 2009-11-30 22:09:24.385647500 +0000
+@@ -11,7 +11,7 @@
+
+ if test "$PHP_PCRE_REGEX" != "yes" && test "$PHP_PCRE_REGEX" != "no"; then
+ AC_MSG_CHECKING([for PCRE headers location])
+- for i in $PHP_PCRE_REGEX $PHP_PCRE_REGEX/include $PHP_PCRE_REGEX/include/pcre $PHP_PCRE_REGEX/local/include; do
++ for i in $PHP_PCRE_REGEX $PHP_PCRE_REGEX/include $PHP_PCRE_REGEX/include/pcre $PHP_PCRE_REGEX/local/include /usr/include; do
+ test -f $i/pcre.h && PCRE_INCDIR=$i
+ done
+
+@@ -21,7 +21,7 @@
+ AC_MSG_RESULT([$PCRE_INCDIR])
+
+ AC_MSG_CHECKING([for PCRE library location])
+- for j in $PHP_PCRE_REGEX $PHP_PCRE_REGEX/$PHP_LIBDIR; do
++ for j in $PHP_PCRE_REGEX $PHP_PCRE_REGEX/$PHP_LIBDIR /usr/$PHP_LIBDIR; do
+ test -f $j/libpcre.a || test -f $j/libpcre.$SHLIB_SUFFIX_NAME && PCRE_LIBDIR=$j
+ done
+
+@@ -43,12 +43,13 @@
+ AC_MSG_ERROR([The PCRE extension requires PCRE library version >= 6.6])
+ fi
+
+- PHP_ADD_LIBRARY_WITH_PATH(pcre, $PCRE_LIBDIR)
++ PHP_ADD_LIBRARY_WITH_PATH(pcre, $PCRE_LIBDIR, PCRE_SHARED_LIBADD)
+
+ AC_DEFINE(HAVE_PCRE, 1, [ ])
+ PHP_ADD_INCLUDE($PCRE_INCDIR)
+- PHP_NEW_EXTENSION(pcre, php_pcre.c, no)
++ PHP_NEW_EXTENSION(pcre, php_pcre.c, $ext_shared)
+ PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h])
++ EXTRA_LIBS="$EXTRA_LIBS -lpcre"
+ else
+ AC_MSG_CHECKING([for PCRE library to use])
+ AC_MSG_RESULT([bundled])
+@@ -59,7 +60,7 @@
+ pcrelib/pcre_ord2utf8.c pcrelib/pcre_refcount.c pcrelib/pcre_study.c \
+ pcrelib/pcre_tables.c pcrelib/pcre_try_flipped.c pcrelib/pcre_valid_utf8.c \
+ pcrelib/pcre_version.c pcrelib/pcre_xclass.c"
+- PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,-I@ext_srcdir@/pcrelib)
++ PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, $ext_shared,,-I@ext_srcdir@/pcrelib)
+ PHP_ADD_BUILD_DIR($ext_builddir/pcrelib)
+ PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcrelib/])
+ AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
+--- php-5.3.1/ext/pcre/php_pcre.h 2009-11-30 20:59:04.046581246 +0200
++++ php-5.3.1.pcre/ext/pcre/php_pcre.h 2009-11-30 21:38:06.435493243 +0000
+@@ -34,7 +34,12 @@
+ #endif
+
+ PHPAPI char *php_pcre_replace(char *regex, int regex_len, char *subject, int subject_len, zval *replace_val, int is_callable_replace, int *result_len, int limit, int *replace_count TSRMLS_DC);
++#if COMPILE_DL_PCRE
++#define pcre_get_compiled_regex pcre_get_compiled_regex_p
++extern PHPAPI pcre* (*pcre_get_compiled_regex)(char *regex, pcre_extra **extra, int *options TSRMLS_DC);
++#else
+ PHPAPI pcre* pcre_get_compiled_regex(char *regex, pcre_extra **extra, int *options TSRMLS_DC);
++#endif
+ PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, int *preg_options, int *coptions TSRMLS_DC);
+
+ extern zend_module_entry pcre_module_entry;
+--- php-5.3.1/ext/pcre/php_pcre.c 2009-11-30 21:10:01.370473754 +0200
++++ php-5.3.1.pcre/ext/pcre/php_pcre.c 2009-11-30 21:38:01.759684456 +0000
+@@ -27,6 +27,11 @@
+
+ #if HAVE_PCRE || HAVE_BUNDLED_PCRE
+
++#if COMPILE_DL_PCRE
++#undef pcre_get_compiled_regex
++PHPAPI pcre* pcre_get_compiled_regex(char *regex, pcre_extra **extra, int *preg_options TSRMLS_DC);
++#endif
++
+ #include "ext/standard/php_string.h"
+
+ #define PREG_PATTERN_ORDER 1
+@@ -153,6 +158,10 @@
+ REGISTER_LONG_CONSTANT("PREG_BAD_UTF8_OFFSET_ERROR", PHP_PCRE_BAD_UTF8_OFFSET_ERROR, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("PCRE_VERSION", (char *)pcre_version(), CONST_CS | CONST_PERSISTENT);
+
++#if COMPILE_DL_PCRE
++ pcre_get_compiled_regex_p = pcre_get_compiled_regex;
++#endif
++
+ return SUCCESS;
+ }
+ /* }}} */
+@@ -429,6 +438,7 @@
+ }
+ /* }}} */
+
++
+ /* {{{ pcre_get_compiled_regex
+ */
+ PHPAPI pcre* pcre_get_compiled_regex(char *regex, pcre_extra **extra, int *preg_options TSRMLS_DC)
+--- php-5.3.1/ext/standard/browscap.c 2009-06-06 02:40:49.000000000 +0000
++++ php-5.3.1.pcre/ext/standard/browscap.c 2009-11-30 21:33:00.775241138 +0000
+@@ -31,6 +31,11 @@
+ static zval *current_section;
+ static char *current_section_name;
+
++#if COMPILE_DL_PCRE
++// will be visible in here
++PHPAPI pcre* (*pcre_get_compiled_regex_p)(char *regex, pcre_extra **extra, int *options TSRMLS_DC);
++#endif
++
+ #define DEFAULT_SECTION_NAME "Default Browser Capability Settings"
+
+ /* OBJECTS_FIXME: This whole extension needs going through. The use of objects looks pretty broken here */
+--- php-5.3.2/sapi/cli/tests/018.phpt~ 2008-03-17 16:05:39.000000000 +0200
++++ php-5.3.2/sapi/cli/tests/018.phpt 2010-03-16 20:41:11.341251246 +0200
+@@ -20,8 +20,6 @@
+ --EXPECTF--
+ [PHP Modules]
+ %a
+-pcre
+-%a
+
+ [Zend Modules]
+ %aDone
--- /dev/null
+--- php-5.2.4/Makefile.global~ 2007-08-31 19:35:54.000000000 +0300
++++ php-5.2.4/Makefile.global 2007-08-31 19:40:18.287528480 +0300
+@@ -21,6 +21,12 @@
+ $(LIBTOOL) --mode=link $(CC) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(phptempdir)/libphp_common.la $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
+ -@$(LIBTOOL) --silent --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1
+
++$(LIBTOOL_SAPI): libphp_common.la $(PHP_SAPI_OBJS)
++ $(LIBTOOL) --mode=link $(CC) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(phptempdir)/libphp_common.la $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
++ -@$(LIBTOOL) --silent --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1
++
++libtool-sapi: $(LIBTOOL_SAPI)
++
+ libs/libphp$(PHP_MAJOR_VERSION).bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
+ $(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp$(PHP_MAJOR_VERSION).so
+
--- /dev/null
+#!/bin/sh
+set -e
+svn=http://svn.php.net/repository/php/php-src
+tag=php_5_3_2
+branch=PHP_5_3
+out=php-branch.diff
+
+d=$-
+filter() {
+ set -$d
+ # remove revno's for smaller diffs
+ sed -e 's,^\([-+]\{3\} .*\)\t(revision [0-9]\+)$,\1,'
+}
+
+old=$svn/tags/$tag
+new=$svn/branches/$branch
+echo >&2 "Running diff: $old -> $new"
+LC_ALL=C svn diff --old=$old --new=$new | filter > $out.tmp
+
+if cmp -s $out{,.tmp}; then
+ echo >&2 "No new diffs..."
+ rm -f $out.tmp
+ exit 0
+fi
+mv -f $out{.tmp,}
--- /dev/null
+diff -ur php-5.3.6-orig//ext/sockets/sockets.c php-5.3.6//ext/sockets/sockets.c
+--- php-5.3.6-orig//ext/sockets/sockets.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6//ext/sockets/sockets.c 2011-05-24 07:09:54.592779164 +0200
+@@ -1333,6 +1333,11 @@
+ break;
+
+ case AF_UNIX:
++ if (addr_len >= sizeof(s_un.sun_path)) {
++ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Path too long", php_sock->type);
++ RETURN_FALSE;
++ }
++
+ memset(&s_un, 0, sizeof(struct sockaddr_un));
+
+ s_un.sun_family = AF_UNIX;
+Tylko w php-5.3.6//ext/sockets: sockets.c~
--- /dev/null
+diff -urbB php-5.0.5.org/scripts/Makefile.frag php-5.0.5/scripts/Makefile.frag
+--- php-5.0.5.org/scripts/Makefile.frag 2005-09-10 21:29:04.884122000 +0200
++++ php-5.0.5/scripts/Makefile.frag 2005-09-10 21:30:09.333324848 +0200
+@@ -4,7 +4,7 @@
+ #
+
+ phpincludedir = $(includedir)/php
+-phpbuilddir = $(libdir)/build
++phpbuilddir = $(libdir)/php/build
+
+ BUILD_FILES = \
+ scripts/phpize.m4 \
+diff -urbB php-5.0.5.org/scripts/phpize.in php-5.0.5/scripts/phpize.in
+--- php-5.0.5.org/scripts/phpize.in 2005-06-15 19:19:41.000000000 +0200
++++ php-5.0.5/scripts/phpize.in 2005-09-10 21:51:45.523274024 +0200
+@@ -3,7 +3,7 @@
+ # Variable declaration
+ prefix='@prefix@'
+ exec_prefix="`eval echo @exec_prefix@`"
+-phpdir="`eval echo @libdir@`/build"
++phpdir="`eval echo @libdir@`/php/build"
+ includedir="`eval echo @includedir@`/php"
+ builddir="`pwd`"
+
--- /dev/null
+; php-cgi-fcgi.ini - configuration used only for cgi-fcgi SAPI
+;
+; Please note that, unlikely in original php distributions, this file
+; is read AFTER (not instead of) reading global /etc/php/php.ini.
+;
+; It allows you to control global settings for all SAPIs in one place
+; and override some settings in SAPI-specific files without need of
+; copying whole large php.ini.
+
+[PHP]
+; Disable logging through FastCGI connection
+; See http://bugs.php.net/bug.php?id=28074
+; fastcgi.logging = 0
+
+; cgi.force_redirect is necessary to provide security running PHP as a CGI under
+; most web servers. Left undefined, PHP turns this on by default. You can
+; turn it off here AT YOUR OWN RISK
+; **You CAN safely turn this off for IIS, in fact, you MUST.**
+; cgi.force_redirect = 1
+
+; if cgi.nph is enabled it will force cgi to always sent Status: 200 with
+; every request.
+; cgi.nph = 1
+
+; if cgi.force_redirect is turned on, and you are not running under Apache or Netscape
+; (iPlanet) web servers, you MAY need to set an environment variable name that PHP
+; will look for to know it is OK to continue execution. Setting this variable MAY
+; cause security issues, KNOW WHAT YOU ARE DOING FIRST.
+; cgi.redirect_status_env = ;
+
+; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's
+; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
+; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
+; this to 1 will cause PHP CGI to fix it's paths to conform to the spec. A setting
+; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
+; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
+cgi.fix_pathinfo=1
+
+; cgi.rfc2616_headers configuration option tells PHP what type of headers to
+; use when sending HTTP response code. If it's set 0 PHP sends Status: header that
+; is supported by Apache. When this option is set to 1 PHP will send
+; RFC2616 compliant header.
+; Default is zero.
+;cgi.rfc2616_headers = 0
+
+[Session]
+session.save_path = /tmp ; argument passed to save_handler
+ ; in the case of files, this is the
+ ; path where data files are stored
+
--- /dev/null
+; php-cli.ini - configuration used only for cli SAPI
+;
+; Please note that, unlikely in original php distributions, this file
+; is read AFTER (not instead of) reading global /etc/php/php.ini.
+;
+; It allows you to control global settings for all SAPIs in one place
+; and override some settings in SAPI-specific files without need of
+; copying whole large php.ini.
+
+[PHP]
+; This combination (display_errors=off; log_errors=on; error_log ="") allows
+; fatal errors go to STDERR only. We set these separately here, that we won't
+; be affected by global php.ini
+display_errors = Off
+log_errors = On
+
+; Disable error logging, in case it was enabled in global php.ini
+error_log = ""
+
+; Whether or not to enable the dl() function.
+; http://php.net/enable-dl
+enable_dl = On
+
+[Session]
+; argument passed to save_handler in the case of files, this is the
+; path where data files are stored.
+session.save_path = /tmp
--- /dev/null
+--- php-5.2.0/scripts/php-config.in 2006-12-14 01:11:33.348180526 +0200
++++ php-5.2.4/scripts/php-config.in 2007-08-31 19:43:04.061307670 +0300
+@@ -2,6 +2,7 @@
+
+ prefix="@prefix@"
+ exec_prefix="@exec_prefix@"
++sysconfdir='@sysconfdir@'
+ version="@PHP_VERSION@"
+ version_id="@PHP_VERSION_ID@"
+ includedir="@includedir@/php"
+@@ -53,6 +54,8 @@
+ echo $extension_dir;;
+ --include-dir)
+ echo $include_dir;;
++--sysconfdir)
++ echo $sysconfdir;;
+ --php-binary)
+ echo $php_binary;;
+ --php-sapis)
+@@ -72,6 +75,7 @@
+ --ldflags [$ldflags]
+ --libs [$libs]
+ --extension-dir [$extension_dir]
++ --sysconfdir [$sysconfdir]
+ --include-dir [$include_dir]
+ --php-binary [$php_binary]
+ --php-sapis [$php_sapis]
--- /dev/null
+--- php-src/main/php_ini.c 2009/05/18 21:28:42 1.173
++++ php-src/main/php_ini.c 2009/06/27 15:22:06 1.174
+@@ -349,7 +349,8 @@
+ char *open_basedir;
+ int free_ini_search_path = 0;
+ zend_file_handle fh;
+-
++ static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
++
+ if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) config_zval_dtor, 1) == FAILURE) {
+ return FAILURE;
+ }
+@@ -372,7 +373,6 @@
+ char *default_location;
+ char *env_location;
+ char *binary_location;
+- static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
+ #ifdef PHP_WIN32
+ char *reg_location;
+ char phprc_path[MAXPATHLEN];
+@@ -608,72 +608,86 @@
+
+ /* Scan and parse any .ini files found in scan path if path not empty. */
+ if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) {
+- struct dirent **namelist;
+ int ndir, i;
+ struct stat sb;
+ char ini_file[MAXPATHLEN];
+- char *p;
++ char *p, *last, *path_copy, *ini_path = NULL;
+ zend_file_handle fh2;
+ zend_llist scanned_ini_list;
+ zend_llist_element *element;
+ int l, total_l = 0;
+
+- if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) {
+- zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
+- memset(&fh2, 0, sizeof(fh2));
+-
+- for (i = 0; i < ndir; i++) {
+-
+- /* check for any file with .ini extension */
+- if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
+- free(namelist[i]);
+- continue;
+- }
+- /* Reset active ini section */
+- RESET_ACTIVE_INI_HASH();
+-
+- if (IS_SLASH(php_ini_scanned_path[php_ini_scanned_path_len - 1])) {
+- snprintf(ini_file, MAXPATHLEN, "%s%s", php_ini_scanned_path, namelist[i]->d_name);
+- } else {
+- snprintf(ini_file, MAXPATHLEN, "%s%c%s", php_ini_scanned_path, DEFAULT_SLASH, namelist[i]->d_name);
+- }
+- if (VCWD_STAT(ini_file, &sb) == 0) {
+- if (S_ISREG(sb.st_mode)) {
+- if ((fh2.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
+- fh2.filename = ini_file;
+- fh2.type = ZEND_HANDLE_FP;
+-
+- if (zend_parse_ini_file(&fh2, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC) == SUCCESS) {
+- /* Here, add it to the list of ini files read */
+- l = strlen(ini_file);
+- total_l += l + 2;
+- p = estrndup(ini_file, l);
+- zend_llist_add_element(&scanned_ini_list, &p);
++ /* List of found ini files */
++ zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
++
++ /* Split by paths_separator and load ini-files from all paths */
++ path_copy = estrdup(php_ini_scanned_path);
++ ini_path = php_strtok_r(path_copy, paths_separator, &last);
++
++ while (ini_path != NULL) {
++ struct dirent **namelist;
++ int ini_path_len = strlen(ini_path);
++
++ if ((ndir = php_scandir(ini_path, &namelist, 0, php_alphasort)) > 0) {
++ memset(&fh2, 0, sizeof(fh2));
++
++ for (i = 0; i < ndir; i++) {
++ /* check for any file with .ini extension */
++ if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
++ free(namelist[i]);
++ continue;
++ }
++ /* Reset active ini section */
++ RESET_ACTIVE_INI_HASH();
++
++ if (IS_SLASH(ini_path[ini_path_len - 1])) {
++ snprintf(ini_file, MAXPATHLEN, "%s%s", ini_path, namelist[i]->d_name);
++ } else {
++ snprintf(ini_file, MAXPATHLEN, "%s%c%s", ini_path, DEFAULT_SLASH, namelist[i]->d_name);
++ }
++ if (VCWD_STAT(ini_file, &sb) == 0) {
++ if (S_ISREG(sb.st_mode)) {
++ if ((fh2.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
++ fh2.filename = ini_file;
++ fh2.type = ZEND_HANDLE_FP;
++
++ /* Reset active ini section */
++ RESET_ACTIVE_INI_HASH();
++
++ if (zend_parse_ini_file(&fh2, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC) == SUCCESS) {
++ /* Here, add it to the list of ini files read */
++ l = strlen(ini_file);
++ total_l += l + 2;
++ p = estrndup(ini_file, l);
++ zend_llist_add_element(&scanned_ini_list, &p);
++ }
+ }
+ }
+ }
++ free(namelist[i]);
+ }
+- free(namelist[i]);
++ free(namelist);
+ }
+- free(namelist);
+-
+- if (total_l) {
+- int php_ini_scanned_files_len = (php_ini_scanned_files) ? strlen(php_ini_scanned_files) + 1 : 0;
+- php_ini_scanned_files = (char *) realloc(php_ini_scanned_files, php_ini_scanned_files_len + total_l + 1);
+- if (!php_ini_scanned_files_len) {
+- *php_ini_scanned_files = '\0';
+- }
+- total_l += php_ini_scanned_files_len;
+- for (element = scanned_ini_list.head; element; element = element->next) {
+- if (php_ini_scanned_files_len) {
+- strlcat(php_ini_scanned_files, ",\n", total_l);
+- }
+- strlcat(php_ini_scanned_files, *(char **)element->data, total_l);
+- strlcat(php_ini_scanned_files, element->next ? ",\n" : "\n", total_l);
++ ini_path = php_strtok_r(NULL, paths_separator, &last);
++ }
++
++ if (total_l) {
++ int php_ini_scanned_files_len = (php_ini_scanned_files) ? strlen(php_ini_scanned_files) + 1 : 0;
++ php_ini_scanned_files = (char *) realloc(php_ini_scanned_files, php_ini_scanned_files_len + total_l + 1);
++ if (!php_ini_scanned_files_len) {
++ *php_ini_scanned_files = '\0';
++ }
++ total_l += php_ini_scanned_files_len;
++ for (element = scanned_ini_list.head; element; element = element->next) {
++ if (php_ini_scanned_files_len) {
++ strlcat(php_ini_scanned_files, ",\n", total_l);
+ }
++ strlcat(php_ini_scanned_files, *(char **)element->data, total_l);
++ strlcat(php_ini_scanned_files, element->next ? ",\n" : "\n", total_l);
+ }
+- zend_llist_destroy(&scanned_ini_list);
+ }
++ efree(path_copy);
++ zend_llist_destroy(&scanned_ini_list);
+ } else {
+ /* Make sure an empty php_ini_scanned_path ends up as NULL */
+ php_ini_scanned_path = NULL;
--- /dev/null
+--- php-5.2.5.orig/ext/curl/interface.c 2008-03-26 17:05:19.000000000 +0100
++++ php-5.2.5/ext/curl/interface.c 2008-03-26 17:09:05.000000000 +0100
+@@ -462,6 +462,14 @@
+ REGISTER_CURL_CONSTANT(CURLOPT_TCP_NODELAY);
+ #endif
+ REGISTER_CURL_CONSTANT(CURLOPT_HTTP200ALIASES);
++
++/* Added constants to support limiting the transfer speed in PHP */
++/* Fixed by Tijnema (admin@tijnema.info) */
++#if LIBCURL_VERSION_NUM > 0x070fff /* CURLOPT_MAX_SEND_SPEED_LARGE and CURLOPT_MAX_SEND_SPEED_LARGE are available since curl 7.16.0 */
++ REGISTER_CURL_CONSTANT(CURLOPT_MAX_SEND_SPEED_LARGE);
++ REGISTER_CURL_CONSTANT(CURLOPT_MAX_RECV_SPEED_LARGE);
++#endif
++
+ REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFMODSINCE);
+ REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFUNMODSINCE);
+ REGISTER_CURL_CONSTANT(CURL_TIMECOND_LASTMOD);
+@@ -1288,6 +1296,12 @@
+ #if LIBCURL_VERSION_NUM > 0x070b01 /* CURLOPT_TCP_NODELAY is available since curl 7.11.2 */
+ case CURLOPT_TCP_NODELAY:
+ #endif
++/* Added case options to support limiting the transfer speed in PHP */
++/* Fixed by Tijnema (admin@tijnema.info) */
++#if LIBCURL_VERSION_NUM > 0x070fff /* CURLOPT_MAX_SEND_SPEED_LARGE and CURLOPT_MAX_SEND_SPEED_LARGE are available since curl 7.16.0 */
++ case CURLOPT_MAX_SEND_SPEED_LARGE:
++ case CURLOPT_MAX_RECV_SPEED_LARGE:
++#endif
+ convert_to_long_ex(zvalue);
+ error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue));
+ break;
--- /dev/null
+--- php-5.2.3/ext/dba/config.m4~ 2007-06-01 10:47:16.524748906 +0300
++++ php-5.2.3/ext/dba/config.m4 2007-06-01 10:51:16.450167741 +0300
+@@ -186,6 +186,8 @@
+ #endif
+ ],[
+ THIS_LIBS=$LIB
++ LDFLAGS=$old_LDFLAGS
++ LIBS=$old_LIBS
+ lib_found=1
+ ])
+ ])
--- /dev/null
+--- ./sapi/cgi/cgi_main.c~ 2007-08-09 02:51:57.000000000 +0300
++++ ./sapi/cgi/cgi_main.c 2007-09-05 20:54:19.390089070 +0300
+@@ -558,12 +558,7 @@
+ request = (fcgi_request*) SG(server_context);
+ if (request) {
+ int len = strlen(message);
+- char *buf = malloc(len+2);
+-
+- memcpy(buf, message, len);
+- memcpy(buf + len, "\n", sizeof("\n"));
+- fcgi_write(request, FCGI_STDERR, buf, len+1);
+- free(buf);
++ fcgi_write(request, FCGI_STDERR, message, len);
+ } else {
+ fprintf(stderr, "%s\n", message);
+ }
--- /dev/null
+Related links:
+
+http://bugs.php.net/bug.php?id=43224 this patch
+
+http://bugs.php.net/bug.php?id=41593
+http://bugs.php.net/bug.php?id=36158
+http://php-fpm.anight.org/
+
+test script too:
+<?php
+echo php_sapi_name(), ' running ', PHP_VERSION, "<br>\n";
+$i = 0;
+while ($i < 35) {
+ echo (++$i), "<br>\n";
+ flush();
+ sleep(1);
+}
+echo "end!<br>\n";
+?>
+
+--- php5.3-200711090930/sapi/cgi/cgi_main.c 2007-11-01 13:32:38.000000000 +0200
++++ php5.3-200711090930-graceful/sapi/cgi/cgi_main.c 2007-11-09 13:34:22.974559020 +0200
+@@ -101,6 +101,9 @@
+ */
+ static int parent = 1;
+
++/* Socket we are listening on incoming connections */
++static int fcgi_fd = 0;
++
+ /**
+ * Process group
+ */
+@@ -1221,6 +1224,21 @@
+ exit(0);
+ }
+
++/**
++ * Graceful shutdown. Close listening sockets.
++ */
++void fastcgi_graceful_shutdown(int signal)
++{
++#ifdef DEBUG_FASTCGI
++ fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid());
++#endif
++
++ /* Close the listening socket so new processes can reuse the same port */
++ closesocket(fcgi_fd);
++ fcgi_fd = 0;
++}
++
++
+ PHP_INI_BEGIN()
+ STD_PHP_INI_ENTRY("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
+ STD_PHP_INI_ENTRY("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals)
+@@ -1328,7 +1346,6 @@
+ int requests = 0;
+ int fastcgi = fcgi_is_fastcgi();
+ char *bindpath = NULL;
+- int fcgi_fd = 0;
+ fcgi_request request;
+ int repeats = 1;
+ int benchmark = 0;
+@@ -1579,9 +1596,13 @@
+ parent = 0;
+
+ /* don't catch our signals */
+- sigaction(SIGTERM, &old_term, 0);
+ sigaction(SIGQUIT, &old_quit, 0);
+ sigaction(SIGINT, &old_int, 0);
++
++ /* call graceful shutdown handler for SIGTERM */
++ act.sa_flags = 0;
++ act.sa_handler = fastcgi_graceful_shutdown;
++ sigaction(SIGTERM, &act, &old_term);
+ break;
+ case -1:
+ perror("php (pre-forking)");
--- /dev/null
+--- php-5.2.0/ext/filter/config.m4~ 2006-01-14 17:04:12.000000000 +0200
++++ php-5.2.0/ext/filter/config.m4 2006-11-20 00:06:09.272529853 +0200
+@@ -10,10 +10,7 @@
+ if test "$PHP_FILTER" != "no"; then
+
+ dnl Check if configure is the PHP core configure
+- if test -n "$PHP_VERSION"; then
+- dnl This extension can not be build as shared when in PHP core
+- ext_shared=no
+- else
++ if test -z "$PHP_VERSION"; then
+ dnl This is PECL build, check if bundled PCRE library is used
+ old_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS=$INCLUDES
--- /dev/null
+--- php-5.3.6/sapi/fpm/php-fpm.conf.in 2011-04-22 15:16:07.304822817 +0300
++++ php-5.3.6/sapi/fpm/php-fpm.conf.in 2011-04-22 15:19:46.991588712 +0300
+@@ -22,7 +22,7 @@
+ ; Pid file
+ ; Note: the default prefix is @EXPANDED_LOCALSTATEDIR@
+ ; Default Value: none
+-;pid = run/php-fpm.pid
++pid = /var/run/php/fpm.pid
+
+ ; Error log file
+ ; Note: the default prefix is @EXPANDED_LOCALSTATEDIR@
+@@ -93,7 +93,7 @@
+ ; specific port;
+ ; '/path/to/unix/socket' - to listen on a unix socket.
+ ; Note: This value is mandatory.
+-listen = 127.0.0.1:9000
++listen = /var/run/php/fpm.sock
+
+ ; Set listen(2) backlog. A value of '-1' means unlimited.
+ ; Default Value: 128 (-1 on FreeBSD and OpenBSD)
+@@ -105,7 +105,7 @@
+ ; must be separated by a comma. If this value is left blank, connections will be
+ ; accepted from any ip address.
+ ; Default Value: any
+-;listen.allowed_clients = 127.0.0.1
++listen.allowed_clients = 127.0.0.1
+
+ ; Set permissions for unix socket, if one is used. In Linux, read/write
+ ; permissions must be set in order to allow connections from a web server. Many
+@@ -159,12 +159,12 @@
+ ; The desired minimum number of idle server processes.
+ ; Note: Used only when pm is set to 'dynamic'
+ ; Note: Mandatory when pm is set to 'dynamic'
+-;pm.min_spare_servers = 5
++pm.min_spare_servers = 5
+
+ ; The desired maximum number of idle server processes.
+ ; Note: Used only when pm is set to 'dynamic'
+ ; Note: Mandatory when pm is set to 'dynamic'
+-;pm.max_spare_servers = 35
++pm.max_spare_servers = 35
+
+ ; The number of requests each child process should execute before respawning.
+ ; This can be useful to work around memory leaks in 3rd party libraries. For
+@@ -277,7 +277,7 @@
+ ; the current environment.
+ ; Default Value: clean env
+ ;env[HOSTNAME] = $HOSTNAME
+-;env[PATH] = /usr/local/bin:/usr/bin:/bin
++env[PATH] = $PATH
+ ;env[TMP] = /tmp
+ ;env[TMPDIR] = /tmp
+ ;env[TEMP] = /tmp
--- /dev/null
+--- php-5.3.3/sapi/fpm/config.m4~ 2010-06-16 11:58:42.000000000 +0300
++++ php-5.3.3/sapi/fpm/config.m4 2010-07-24 22:32:25.642457281 +0300
+@@ -600,7 +600,7 @@
+ BUILD_FPM="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_SAPI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(SAPI_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)"
+ ;;
+ *)
+- BUILD_FPM="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_SAPI_OBJS) \$(EXTRA_LIBS) \$(SAPI_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)"
++ BUILD_FPM="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) libphp_common.la \$(PHP_SAPI_OBJS) \$(EXTRA_LIBS) \$(SAPI_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)"
+ ;;
+ esac
+
+--- php-5.3.3/sapi/fpm/Makefile.frag~ 2010-05-30 01:00:43.000000000 +0300
++++ php-5.3.3/sapi/fpm/Makefile.frag 2010-07-24 22:33:51.945781258 +0300
+@@ -3,7 +3,7 @@
+ $(builddir)/fpm:
+ @mkdir -p $(builddir)/fpm
+
+-$(SAPI_FPM_PATH): $(builddir)/fpm $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(SAPI_EXTRA_DEPS)
++$(SAPI_FPM_PATH): $(builddir)/fpm libphp_common.la $(PHP_SAPI_OBJS) $(SAPI_EXTRA_DEPS)
+ $(BUILD_FPM)
+
+ $(builddir)/fpm/fpm_conf.lo: $(builddir)/../../main/build-defs.h
--- /dev/null
+#!/bin/sh
+#
+# php-fpm PHP FastCGI Process Manager
+#
+# chkconfig: 345 80 30
+#
+# description: PHP FastCGI Process Manager
+#
+# processname: php-fpm
+# config: /etc/php/php-fpm.conf
+# pidfile: /var/run/php/fpm.pid
+#
+# $Id$
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+pidfile=/var/run/php/fpm.pid
+
+start() {
+ # Check if the service is already running?
+ if [ ! -f /var/lock/subsys/php-fpm ]; then
+ msg_starting "PHP FastCGI Process Manager"
+ daemon --pidfile $pidfile /usr/sbin/php-fpm --fpm-config /etc/php/php-fpm.conf
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/php-fpm
+ else
+ msg_already_running "PHP FastCGI Process Manager"
+ fi
+}
+
+stop() {
+ if [ -f /var/lock/subsys/php-fpm ]; then
+ # Stop daemons.
+ msg_stopping "PHP FastCGI Process Manager"
+ # always gracefully shut down php-fpm
+ /sbin/start-stop-daemon -q --stop -s QUIT --retry QUIT/600/TERM/10 --pidfile $pidfile
+ [ "$?" -eq 0 ] && ok || fail
+ rm -f /var/lock/subsys/php-fpm
+ else
+ msg_not_running "PHP FastCGI Process Manager"
+ fi
+}
+
+reload() {
+ local sig=${1:-HUP}
+ local retnr=${2:-7}
+ if [ -f /var/lock/subsys/php-fpm ]; then
+ msg_reloading "PHP FastCGI Process Manager"
+ killproc --pidfile $pidfile php-fpm -$sig
+ RETVAL=$?
+ else
+ msg_not_running "PHP FastCGI Process Manager"
+ RETVAL=$retnr
+ fi
+}
+
+condrestart() {
+ if [ -f /var/lock/subsys/php-fpm ]; then
+ stop
+ start
+ else
+ msg_not_running "PHP FastCGI Process Manager"
+ RETVAL=$1
+ fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop|quit)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ try-restart)
+ condrestart 0
+ ;;
+ reload|force-reload)
+ reload USR2 7
+ ;;
+ flush-logs|logrotate)
+ reload USR1 0
+ ;;
+ status)
+ status php-fpm
+ RETVAL=$?
+ ;;
+ *)
+ msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|flush-logs|status}"
+ exit 3
+ ;;
+esac
+
+exit $RETVAL
--- /dev/null
+/var/log/fpm.log
+/var/log/fpm-slow.log
+{
+ notifempty
+ missingok
+ create 600 root root
+ sharedscripts
+ postrotate
+ /sbin/service php-fpm flush-logs > /dev/null
+ endscript
+}
--- /dev/null
+diff -ur php5.3-200812262130/ext/gd/config.m4 mod/ext/gd/config.m4
+--- php5.3-200812262130/ext/gd/config.m4 2008-07-18 04:34:20.000000000 +0200
++++ mod/ext/gd/config.m4 2008-12-27 01:12:23.000000000 +0100
+@@ -255,6 +255,7 @@
+ PHP_CHECK_LIBRARY(gd, gdFreeFontCache, [AC_DEFINE(HAVE_GD_FREEFONTCACHE, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ])
+ PHP_CHECK_LIBRARY(gd, gdFontCacheMutexSetup, [AC_DEFINE(HAVE_GD_FONTMUTEX, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ])
+ PHP_CHECK_LIBRARY(gd, gdNewDynamicCtxEx, [AC_DEFINE(HAVE_GD_DYNAMIC_CTX_EX, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ])
++ PHP_CHECK_LIBRARY(gd, gdImageRotate, [AC_DEFINE(HAVE_GD_ROTATE, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ])
+ ])
+
+ dnl
+@@ -308,6 +309,7 @@
+ AC_DEFINE(HAVE_GD_FONTMUTEX, 1, [ ])
+ AC_DEFINE(HAVE_GD_DYNAMIC_CTX_EX, 1, [ ])
+ AC_DEFINE(HAVE_GD_GIF_CTX, 1, [ ])
++ AC_DEFINE(HAVE_GD_ROTATE, 1, [ ])
+
+ dnl Make sure the libgd/ is first in the include path
+ GDLIB_CFLAGS="-DHAVE_LIBPNG"
+diff -ur php5.3-200812262130/ext/gd/gd.c mod/ext/gd/gd.c
+--- php5.3-200812262130/ext/gd/gd.c 2008-12-12 14:35:20.000000000 +0100
++++ mod/ext/gd/gd.c 2008-12-27 01:18:43.000000000 +0100
+@@ -296,7 +296,7 @@
+ ZEND_END_ARG_INFO()
+ #endif
+
+-#ifdef HAVE_GD_BUNDLED
++#ifdef HAVE_GD_ROTATE
+ ZEND_BEGIN_ARG_INFO_EX(arginfo_imagerotate, 0, 0, 3)
+ ZEND_ARG_INFO(0, im)
+ ZEND_ARG_INFO(0, angle)
+@@ -927,9 +927,12 @@
+ PHP_FE(imagegrabscreen, arginfo_imagegrabscreen)
+ #endif
+
++#ifdef HAVE_GD_ROTATE
++ PHP_FE(imagerotate, arginfo_imagerotate)
++#endif
++
+ #ifdef HAVE_GD_BUNDLED
+- PHP_FE(imagerotate, arginfo_imagerotate)
+- PHP_FE(imageantialias, arginfo_imageantialias)
++ PHP_FE(imageantialias, arginfo_imageantialias)
+ #endif
+
+ #if HAVE_GD_IMAGESETTILE
+@@ -1079,7 +1082,7 @@
+ PHP_INI_ENTRY("gd.jpeg_ignore_warning", "0", PHP_INI_ALL, NULL)
+ PHP_INI_END()
+ /* }}} */
+-
++
+ /* {{{ php_free_gd_image
+ */
+ static void php_free_gd_image(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+@@ -1140,7 +1143,7 @@
+ #endif
+
+ REGISTER_INI_ENTRIES();
+-
++
+ REGISTER_LONG_CONSTANT("IMG_GIF", 1, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMG_JPG", 2, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMG_JPEG", 2, CONST_CS | CONST_PERSISTENT);
+@@ -1168,11 +1171,14 @@
+ #ifdef GD2_FMT_COMPRESSED
+ REGISTER_LONG_CONSTANT("IMG_GD2_COMPRESSED", GD2_FMT_COMPRESSED, CONST_CS | CONST_PERSISTENT);
+ #endif
+-#if HAVE_GD_BUNDLED
++#if HAVE_GD_ROTATE
+ REGISTER_LONG_CONSTANT("IMG_EFFECT_REPLACE", gdEffectReplace, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMG_EFFECT_ALPHABLEND", gdEffectAlphaBlend, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMG_EFFECT_NORMAL", gdEffectNormal, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMG_EFFECT_OVERLAY", gdEffectOverlay, CONST_CS | CONST_PERSISTENT);
++#endif
++
++#if HAVE_GD_BUNDLED
+ REGISTER_LONG_CONSTANT("GD_BUNDLED", 1, CONST_CS | CONST_PERSISTENT);
+
+ /* Section Filters */
+@@ -1760,7 +1766,7 @@
+ long cx, cy, w, h, ST, E, col, style;
+ gdImagePtr im;
+ int e, st;
+-
++
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllllllll", &IM, &cx, &cy, &w, &h, &ST, &E, &col, &style) == FAILURE) {
+ return;
+ }
+@@ -2008,7 +2014,7 @@
+ if ( handle == 0 ) {
+ goto clean;
+ }
+- pPrintWindow = (tPrintWindow) GetProcAddress(handle, "PrintWindow");
++ pPrintWindow = (tPrintWindow) GetProcAddress(handle, "PrintWindow");
+
+ if ( pPrintWindow ) {
+ pPrintWindow(window, memDC, (UINT) client_area);
+@@ -2105,7 +2111,7 @@
+ /* }}} */
+ #endif /* PHP_WIN32 */
+
+-#ifdef HAVE_GD_BUNDLED
++#ifdef HAVE_GD_ROTATE
+ /* {{{ proto resource imagerotate(resource src_im, float angle, int bgdcolor [, int ignoretransparent])
+ Rotate an image using a custom angle */
+ PHP_FUNCTION(imagerotate)
+@@ -3362,7 +3368,7 @@
+ {
+ zval *IM;
+ gdImagePtr im;
+-
++
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &IM) == FAILURE) {
+ return;
+ }
+@@ -3946,7 +3952,7 @@
+ if (zend_hash_get_current_data_ex(HASH_OF(EXT), (void **) &item, &pos) == FAILURE) {
+ continue;
+ }
+-
++
+ if (strcmp("linespacing", key) == 0) {
+ convert_to_double_ex(item);
+ strex.flags |= gdFTEX_LINESPACE;
+@@ -3972,7 +3978,7 @@
+ #endif
+
+ PHP_GD_CHECK_OPEN_BASEDIR((char *)fontname, "Invalid font filename");
+-
++
+ #ifdef USE_GD_IMGSTRTTF
+ # if HAVE_GD_STRINGFTEX
+ if (extended) {
+@@ -4373,11 +4379,11 @@
+ if (argc != 3 && argc != 6) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
+-
++
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "srl|lld", &str, &str_len, &fnt, &sz, &sp, &wd, &angle) == FAILURE) {
+ return;
+ }
+-
++
+ if (argc == 6) {
+ space = sp;
+ add_width = wd;
+@@ -4562,7 +4568,7 @@
+ #ifdef HAVE_GD_JPG
+ long ignore_warning;
+ #endif
+-
++
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sslll", &f_org, &f_org_len, &f_dest, &f_dest_len, &height, &width, &threshold) == FAILURE) {
+ return;
+ }
+diff -ur php5.3-200812262130/ext/gd/php_gd.h mod/ext/gd/php_gd.h
+--- php5.3-200812262130/ext/gd/php_gd.h 2008-07-18 04:34:20.000000000 +0200
++++ mod/ext/gd/php_gd.h 2008-12-27 01:20:04.000000000 +0100
+@@ -119,8 +119,11 @@
+ PHP_FUNCTION(imagegrabscreen);
+ #endif
+
+-#ifdef HAVE_GD_BUNDLED
++#ifdef HAVE_GD_ROTATE
+ PHP_FUNCTION(imagerotate);
++#endif
++
++#ifdef HAVE_GD_BUNDLED
+ PHP_FUNCTION(imageantialias);
+ #endif
+
--- /dev/null
+Provides get/set ANNOTATIONS support to PHP. [Version: 5.2.6]
+
+diff -r 76412c484360 ext/imap/php_imap.c
+--- a/ext/imap/php_imap.c Wed Dec 23 22:18:41 2009 +0100
++++ b/ext/imap/php_imap.c Wed Dec 23 22:46:34 2009 +0100
+@@ -161,6 +161,22 @@
+ ZEND_ARG_INFO(0, mailbox)
+ ZEND_END_ARG_INFO()
+ #endif
++#if defined(HAVE_IMAP2005)
++ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_setannotation, 0, 0, 5)
++ ZEND_ARG_INFO(0, stream_id)
++ ZEND_ARG_INFO(0, mailbox)
++ ZEND_ARG_INFO(0, entry)
++ ZEND_ARG_INFO(0, attr)
++ ZEND_ARG_INFO(0, value)
++ZEND_END_ARG_INFO()
++
++ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_getannotation, 0, 0, 4)
++ ZEND_ARG_INFO(0, stream_id)
++ ZEND_ARG_INFO(0, mailbox)
++ ZEND_ARG_INFO(0, entry)
++ ZEND_ARG_INFO(0, attr)
++ZEND_END_ARG_INFO()
++#endif
+
+ ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_expunge, 0, 0, 1)
+ ZEND_ARG_INFO(0, stream_id)
+@@ -402,6 +418,11 @@
+ ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_status, 0, 0, 3)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, mailbox)
++ ZEND_ARG_INFO(0, options)
++ZEND_END_ARG_INFO()
++
++ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_status_current, 0, 0, 2)
++ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, options)
+ ZEND_END_ARG_INFO()
+
+@@ -504,6 +525,7 @@
+ PHP_FE(imap_binary, arginfo_imap_binary)
+ PHP_FE(imap_utf8, arginfo_imap_utf8)
+ PHP_FE(imap_status, arginfo_imap_status)
++ PHP_FE(imap_status_current, arginfo_imap_status_current)
+ PHP_FE(imap_mailboxmsginfo, arginfo_imap_mailboxmsginfo)
+ PHP_FE(imap_setflag_full, arginfo_imap_setflag_full)
+ PHP_FE(imap_clearflag_full, arginfo_imap_clearflag_full)
+@@ -534,6 +556,10 @@
+ PHP_FE(imap_setacl, arginfo_imap_setacl)
+ PHP_FE(imap_getacl, arginfo_imap_getacl)
+ #endif
++#if defined(HAVE_IMAP2005)
++ PHP_FE(imap_setannotation, arginfo_imap_setannotation)
++ PHP_FE(imap_getannotation, arginfo_imap_getannotation)
++#endif
+
+ PHP_FE(imap_mail, arginfo_imap_mail)
+
+@@ -795,6 +821,30 @@
+ /* }}} */
+ #endif
+
++#if defined(HAVE_IMAP2005)
++/* {{{ mail_getannotation
++ *
++ * Mail GET_ANNOTATION callback
++ * Called via the mail_parameter function in c-client:src/c-client/mail.c
++ */
++void mail_getannotation(MAILSTREAM *stream, ANNOTATION *alist)
++{
++ ANNOTATION_VALUES *cur;
++
++ TSRMLS_FETCH();
++
++ /* walk through the ANNOTATION_VALUES */
++
++ for(cur = alist->values; cur; cur = cur->next) {
++ if (cur->value)
++ add_assoc_stringl(IMAPG(imap_annotation_list), cur->attr, cur->value, strlen(cur->value), 1);
++ else
++ add_assoc_stringl(IMAPG(imap_annotation_list), cur->attr, "", 0, 1);
++ }
++}
++/* }}} */
++#endif
++
+ /* {{{ PHP_GINIT_FUNCTION
+ */
+ static PHP_GINIT_FUNCTION(imap)
+@@ -820,6 +870,7 @@
+ #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
+ imap_globals->quota_return = NIL;
+ imap_globals->imap_acl_list = NIL;
++ imap_globals->imap_annotation_list = NIL;
+ #endif
+ imap_globals->gets_stream = NIL;
+ }
+@@ -1475,7 +1526,119 @@
+ }
+ /* }}} */
+ #endif /* HAVE_IMAP2000 || HAVE_IMAP2001 */
+-
++
++#if defined(HAVE_IMAP2005)
++
++/* {{{ proto bool imap_setannotation(resource stream_id, string mailbox, string entry, string attr, string value)
++ Sets an annotation for a given mailbox */
++PHP_FUNCTION(imap_setannotation)
++{
++ zval **streamind, **mailbox, **entry, **attr, **value;
++ pils *imap_le_struct;
++ long ret;
++
++ // TODO: Use zend_parse_parameters here
++ if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &streamind, &mailbox, &entry, &attr, &value) == FAILURE) {
++ ZEND_WRONG_PARAM_COUNT();
++ }
++
++ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
++
++ convert_to_string_ex(mailbox);
++ convert_to_string_ex(entry);
++ convert_to_string_ex(attr);
++ convert_to_string_ex(value);
++
++ // create annotation object
++ ANNOTATION *annotation = mail_newannotation();
++ if (!annotation)
++ RETURN_FALSE;
++ annotation->values = mail_newannotationvalue();
++ if (!annotation->values) {
++ mail_free_annotation(&annotation);
++ RETURN_FALSE;
++ }
++
++ // fill in annotation values
++ annotation->mbox = Z_STRVAL_PP(mailbox);
++ annotation->entry = Z_STRVAL_PP(entry);
++ annotation->values->attr = Z_STRVAL_PP(attr);
++ annotation->values->value = Z_STRVAL_PP(value);
++
++ ret = imap_setannotation(imap_le_struct->imap_stream, annotation);
++
++ // make sure mail_free_annotation doesn't free our variables
++ annotation->mbox = NULL;
++ annotation->entry = NULL;
++ annotation->values->attr = NULL;
++ annotation->values->value = NULL;
++ mail_free_annotation(&annotation);
++
++ RETURN_BOOL(ret);
++}
++/* }}} */
++
++/* {{{ proto array imap_getannotation(resource stream_id, string mailbox, string entry, string attr)
++ Gets the ACL for a given mailbox */
++PHP_FUNCTION(imap_getannotation)
++{
++ zval **streamind, **mailbox, **entry, **attr;
++ pils *imap_le_struct;
++ long ret;
++
++ if(ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &streamind, &mailbox, &entry, &attr) == FAILURE) {
++ ZEND_WRONG_PARAM_COUNT();
++ }
++
++ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
++
++ convert_to_string_ex(mailbox);
++ convert_to_string_ex(entry);
++ convert_to_string_ex(attr);
++
++ /* initializing the special array for the return values */
++ if (array_init(return_value) == FAILURE) {
++ RETURN_FALSE;
++ }
++
++ // fillup calling parameters
++ STRINGLIST *entries = mail_newstringlist();
++ if (!entries)
++ RETURN_FALSE;
++
++ STRINGLIST *cur = entries;
++ cur->text.data = (unsigned char *)cpystr(Z_STRVAL_PP(entry));
++ cur->text.size = Z_STRLEN_PP(entry);
++ cur->next = NIL;
++
++ STRINGLIST *attributes = mail_newstringlist();
++ if (!attributes)
++ RETURN_FALSE;
++ cur = attributes;
++ cur->text.data = (unsigned char *)cpystr (Z_STRVAL_PP(attr));
++ cur->text.size = Z_STRLEN_PP(attr);
++ cur->next = NIL;
++
++ IMAPG(imap_annotation_list) = return_value;
++
++ /* set the callback for the GET_ANNOTATION function */
++ mail_parameters(NIL, SET_ANNOTATION, (void *) mail_getannotation);
++ ret = imap_getannotation(imap_le_struct->imap_stream, Z_STRVAL_PP(mailbox), entries, attributes);
++
++ mail_free_stringlist(&entries);
++ mail_free_stringlist(&attributes);
++
++ if (!ret) {
++ zval_dtor(return_value);
++ RETURN_FALSE;
++ }
++
++ IMAPG(imap_annotation_list) = NIL;
++}
++/* }}} */
++
++#endif /* HAVE_IMAP2005 */
++
+ /* {{{ proto bool imap_expunge(resource stream_id)
+ Permanently delete all messages marked for deletion */
+ PHP_FUNCTION(imap_expunge)
+@@ -3118,6 +3281,42 @@
+ }
+ /* }}} */
+
++/* {{{ proto object imap_status_current(resource stream_id, int options)
++ Get (cached) status info from current mailbox */
++PHP_FUNCTION(imap_status_current)
++{
++ zval **streamind, **pflags;
++ pils *imap_le_struct;
++ long flags = 0L;
++
++ if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &pflags) == FAILURE) {
++ ZEND_WRONG_PARAM_COUNT();
++ }
++
++ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
++
++ convert_to_long_ex(pflags);
++ flags = Z_LVAL_PP(pflags);
++
++ if (object_init(return_value) == FAILURE) {
++ RETURN_FALSE;
++ }
++
++ if (flags & SA_MESSAGES) {
++ add_property_long(return_value, "messages", imap_le_struct->imap_stream->nmsgs);
++ }
++ if (flags & SA_RECENT) {
++ add_property_long(return_value, "recent", imap_le_struct->imap_stream->recent);
++ }
++ if (flags & SA_UIDNEXT) {
++ add_property_long(return_value, "uidnext", imap_le_struct->imap_stream->uid_last+1);
++ }
++ if (flags & SA_UIDVALIDITY) {
++ add_property_long(return_value, "uidvalidity", imap_le_struct->imap_stream->uid_validity);
++ }
++}
++/* }}} */
++
+ /* {{{ proto object imap_status(resource stream_id, string mailbox, int options)
+ Get status info from a mailbox */
+ PHP_FUNCTION(imap_status)
+diff -r 76412c484360 ext/imap/php_imap.h
+--- a/ext/imap/php_imap.h Wed Dec 23 22:18:41 2009 +0100
++++ b/ext/imap/php_imap.h Wed Dec 23 22:46:34 2009 +0100
+@@ -153,6 +153,7 @@
+ PHP_FUNCTION(imap_lsub_full);
+ PHP_FUNCTION(imap_create);
+ PHP_FUNCTION(imap_rename);
++PHP_FUNCTION(imap_status_current);
+ PHP_FUNCTION(imap_status);
+ PHP_FUNCTION(imap_bodystruct);
+ PHP_FUNCTION(imap_fetch_overview);
+@@ -173,6 +174,9 @@
+ PHP_FUNCTION(imap_thread);
+ PHP_FUNCTION(imap_timeout);
+
++// TODO: Needs fixing in configure in
++#define HAVE_IMAP2005 1
++
+ #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
+ PHP_FUNCTION(imap_get_quota);
+ PHP_FUNCTION(imap_get_quotaroot);
+@@ -180,7 +184,10 @@
+ PHP_FUNCTION(imap_setacl);
+ PHP_FUNCTION(imap_getacl);
+ #endif
+-
++#if defined(HAVE_IMAP2005)
++PHP_FUNCTION(imap_setannotation);
++PHP_FUNCTION(imap_getannotation);
++#endif
+
+ ZEND_BEGIN_MODULE_GLOBALS(imap)
+ char *imap_user;
+@@ -211,6 +218,9 @@
+ zval **quota_return;
+ zval *imap_acl_list;
+ #endif
++#if defined(HAVE_IMAP2005)
++ zval *imap_annotation_list;
++#endif
+ /* php_stream for php_mail_gets() */
+ php_stream *gets_stream;
+ ZEND_END_MODULE_GLOBALS(imap)
--- /dev/null
+diff -r 5daa8cce8706 ext/imap/php_imap.c
+--- a/ext/imap/php_imap.c Wed Dec 23 22:46:34 2009 +0100
++++ b/ext/imap/php_imap.c Wed Dec 23 22:49:02 2009 +0100
+@@ -157,6 +157,11 @@
+ ZEND_END_ARG_INFO()
+
+ ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_getacl, 0, 0, 2)
++ ZEND_ARG_INFO(0, stream_id)
++ ZEND_ARG_INFO(0, mailbox)
++ZEND_END_ARG_INFO()
++
++ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_myrights, 0, 0, 2)
+ ZEND_ARG_INFO(0, stream_id)
+ ZEND_ARG_INFO(0, mailbox)
+ ZEND_END_ARG_INFO()
+@@ -555,6 +560,7 @@
+ PHP_FE(imap_set_quota, arginfo_imap_set_quota)
+ PHP_FE(imap_setacl, arginfo_imap_setacl)
+ PHP_FE(imap_getacl, arginfo_imap_getacl)
++ PHP_FE(imap_myrights, arginfo_imap_myrights)
+ #endif
+ #if defined(HAVE_IMAP2005)
+ PHP_FE(imap_setannotation, arginfo_imap_setannotation)
+@@ -817,6 +823,20 @@
+ for(; alist; alist = alist->next) {
+ add_assoc_stringl(IMAPG(imap_acl_list), alist->identifier, alist->rights, strlen(alist->rights), 1);
+ }
++}
++/* }}} */
++
++/* {{{ mail_myrights
++ *
++ * Mail MYRIGHTS callback
++ * Called via the mail_parameter function in c-client:src/c-client/mail.c
++ */
++void mail_myrights(MAILSTREAM *stream, char *mailbox, char *rights)
++{
++ TSRMLS_FETCH();
++
++ ZVAL_STRING(IMAPG(imap_acl_list), rights, 1)
++
+ }
+ /* }}} */
+ #endif
+@@ -1525,6 +1545,36 @@
+ IMAPG(imap_acl_list) = NIL;
+ }
+ /* }}} */
++
++/* {{{ proto string imap_myrights(resource stream_id, string mailbox)
++ Gets my rights (ACL) for a given mailbox */
++PHP_FUNCTION(imap_myrights)
++{
++ zval **streamind, **mailbox;
++ pils *imap_le_struct;
++
++ if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &mailbox) == FAILURE) {
++ ZEND_WRONG_PARAM_COUNT();
++ }
++
++ ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
++
++ convert_to_string_ex(mailbox);
++
++ IMAPG(imap_acl_list) = return_value;
++
++ /* set the callback for the GET_ACL function */
++ mail_parameters(NIL, SET_MYRIGHTS, (void *) mail_myrights);
++ if(!imap_myrights(imap_le_struct->imap_stream, Z_STRVAL_PP(mailbox))) {
++ php_error(E_WARNING, "c-client imap_myrights failed");
++ zval_dtor(return_value);
++ RETURN_FALSE;
++ }
++
++ IMAPG(imap_acl_list) = NIL;
++}
++/* }}} */
++
+ #endif /* HAVE_IMAP2000 || HAVE_IMAP2001 */
+
+ #if defined(HAVE_IMAP2005)
+diff -r 5daa8cce8706 ext/imap/php_imap.h
+--- a/ext/imap/php_imap.h Wed Dec 23 22:46:34 2009 +0100
++++ b/ext/imap/php_imap.h Wed Dec 23 22:49:02 2009 +0100
+@@ -183,6 +183,7 @@
+ PHP_FUNCTION(imap_set_quota);
+ PHP_FUNCTION(imap_setacl);
+ PHP_FUNCTION(imap_getacl);
++PHP_FUNCTION(imap_myrights);
+ #endif
+ #if defined(HAVE_IMAP2005)
+ PHP_FUNCTION(imap_setannotation);
--- /dev/null
+--- php-5.2.0/configure.in.includedir
++++ php-5.2.0/configure.in
+@@ -1101,7 +1101,7 @@
+ EXPANDED_DATADIR=$datadir
+ EXPANDED_PHP_CONFIG_FILE_PATH=`eval echo "$PHP_CONFIG_FILE_PATH"`
+ EXPANDED_PHP_CONFIG_FILE_SCAN_DIR=`eval echo "$PHP_CONFIG_FILE_SCAN_DIR"`
+-INCLUDE_PATH=.:$EXPANDED_PEAR_INSTALLDIR
++INCLUDE_PATH=.:$EXPANDED_PEAR_INSTALLDIR:${EXPANDED_DATADIR}/php
+
+ exec_prefix=$old_exec_prefix
+ libdir=$old_libdir
--- /dev/null
+--- php-5.3.4/php.ini~ 2010-12-12 23:03:42.000000000 +0200
++++ php-5.3.4/php.ini 2010-12-12 23:05:56.583592856 +0200
+@@ -223,7 +223,7 @@
+ ; Development Value: Off
+ ; Production Value: Off
+ ; http://php.net/short-open-tag
+-short_open_tag = Off
++short_open_tag = On
+
+ ; Allow ASP-style <% %> tags.
+ ; http://php.net/asp-tags
+@@ -428,7 +428,7 @@
+ ; threat in any way, but it makes it possible to determine whether you use PHP
+ ; on your server or not.
+ ; http://php.net/expose-php
+-expose_php = On
++expose_php = Off
+
+ ;;;;;;;;;;;;;;;;;;;
+ ; Resource Limits ;
+@@ -804,7 +804,7 @@
+
+ ; Directory in which the loadable extensions (modules) reside.
+ ; http://php.net/extension-dir
+-; extension_dir = "./"
++extension_dir = "/usr/lib/php"
+ ; On windows:
+ ; extension_dir = "ext"
+
+@@ -812,54 +812,7 @@
+ ; properly in multithreaded servers, such as IIS or Zeus, and is automatically
+ ; disabled on them.
+ ; http://php.net/enable-dl
+-enable_dl = Off
+-
+-; cgi.force_redirect is necessary to provide security running PHP as a CGI under
+-; most web servers. Left undefined, PHP turns this on by default. You can
+-; turn it off here AT YOUR OWN RISK
+-; **You CAN safely turn this off for IIS, in fact, you MUST.**
+-; http://php.net/cgi.force-redirect
+-;cgi.force_redirect = 1
+-
+-; if cgi.nph is enabled it will force cgi to always sent Status: 200 with
+-; every request. PHP's default behavior is to disable this feature.
+-;cgi.nph = 1
+-
+-; if cgi.force_redirect is turned on, and you are not running under Apache or Netscape
+-; (iPlanet) web servers, you MAY need to set an environment variable name that PHP
+-; will look for to know it is OK to continue execution. Setting this variable MAY
+-; cause security issues, KNOW WHAT YOU ARE DOING FIRST.
+-; http://php.net/cgi.redirect-status-env
+-;cgi.redirect_status_env = ;
+-
+-; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's
+-; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
+-; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
+-; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting
+-; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
+-; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
+-; http://php.net/cgi.fix-pathinfo
+-;cgi.fix_pathinfo=1
+-
+-; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate
+-; security tokens of the calling client. This allows IIS to define the
+-; security context that the request runs under. mod_fastcgi under Apache
+-; does not currently support this feature (03/17/2002)
+-; Set to 1 if running under IIS. Default is zero.
+-; http://php.net/fastcgi.impersonate
+-;fastcgi.impersonate = 1;
+-
+-; Disable logging through FastCGI connection. PHP's default behavior is to enable
+-; this feature.
+-;fastcgi.logging = 0
+-
+-; cgi.rfc2616_headers configuration option tells PHP what type of headers to
+-; use when sending HTTP response code. If it's set 0 PHP sends Status: header that
+-; is supported by Apache. When this option is set to 1 PHP will send
+-; RFC2616 compliant header.
+-; Default is zero.
+-; http://php.net/cgi.rfc2616-headers
+-;cgi.rfc2616_headers = 0
++enable_dl = Off
+
+ ;;;;;;;;;;;;;;;;
+ ; File Uploads ;
+@@ -876,11 +876,7 @@
+ ;
+ ; extension=modulename.extension
+ ;
+-; For example, on Windows:
+-;
+-; extension=msql.dll
+-;
+-; ... or under UNIX:
++; For example under UNIX:
+ ;
+ ; extension=msql.so
+ ;
+@@ -887,39 +887,8 @@
+ ; If you only provide the name of the extension, PHP will look for it in its
+ ; default extension directory.
+ ;
+-; Windows Extensions
+-; Note that ODBC support is built in, so no dll is needed for it.
+-; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
+-; extension folders as well as the separate PECL DLL download (PHP 5).
+-; Be sure to appropriately set the extension_dir directive.
+-;
+-;extension=php_bz2.dll
+-;extension=php_curl.dll
+-;extension=php_fileinfo.dll
+-;extension=php_gd2.dll
+-;extension=php_gettext.dll
+-;extension=php_gmp.dll
+-;extension=php_intl.dll
+-;extension=php_imap.dll
+-;extension=php_interbase.dll
+-;extension=php_ldap.dll
+-;extension=php_mbstring.dll
+-;extension=php_exif.dll ; Must be after mbstring as it depends on it
+-;extension=php_mysql.dll
+-;extension=php_mysqli.dll
+-;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client
+-;extension=php_oci8_11g.dll ; Use with Oracle 11g Instant Client
+-;extension=php_openssl.dll
+-;extension=php_pdo_firebird.dll
+-;extension=php_pdo_mssql.dll
+-;extension=php_pdo_mysql.dll
+-;extension=php_pdo_oci.dll
+-;extension=php_pdo_odbc.dll
+-;extension=php_pdo_pgsql.dll
+-;extension=php_pdo_sqlite.dll
+-;extension=php_pgsql.dll
+-;extension=php_pspell.dll
+-;extension=php_shmop.dll
++; Ideally in PLD Linux you should install appropriate php-<extension> or
++; php-pecl-<extension> package.
+
+ ; The MIBS data available in the PHP distribution must be installed.
+ ; See http://www.php.net/manual/en/snmp.installation.php
+@@ -1235,6 +1140,9 @@
+ ; http://php.net/mysql.connect-timeout
+ mysql.connect_timeout = 60
+
++; The name of the character set to use as the default character set.
++;mysql.connect_charset=utf8
++
+ ; Trace mode. When trace_mode is active (=On), warnings for table/index scans and
+ ; SQL-Errors will be displayed.
+ ; http://php.net/mysql.trace-mode
+@@ -1274,6 +1182,9 @@
+ ; http://php.net/mysqli.default-socket
+ mysqli.default_socket =
+
++; The name of the character set to use as the default character set.
++;mysqli.connect_charset=utf8
++
+ ; Default host for mysql_connect() (doesn't apply in safe mode).
+ ; http://php.net/mysqli.default-host
+ mysqli.default_host =
+@@ -1440,7 +1351,7 @@
+
+ [browscap]
+ ; http://php.net/browscap
+-;browscap = extra/browscap.ini
++browscap = /etc/php/browscap.ini
+
+ [Session]
+ ; Handler used to store/retrieve data.
+@@ -1863,7 +1774,7 @@
+
+ ; Sets the directory name where SOAP extension will put cache files.
+ ; http://php.net/soap.wsdl-cache-dir
+-soap.wsdl_cache_dir="/tmp"
++soap.wsdl_cache_dir="/var/run/php"
+
+ ; (time to live) Sets the number of second while cached file will be used
+ ; instead of original one.
--- /dev/null
+--- php-5.3.3/acinclude.m4.orig 2010-10-19 21:38:42.000000000 +0200
++++ php-5.3.3/acinclude.m4 2010-10-19 22:53:11.792893220 +0200
+@@ -2252,7 +2252,7 @@
+ KERBEROS_LIBS=`$KRB5_CONFIG --libs gssapi`
+ KERBEROS_CFLAGS=`$KRB5_CONFIG --cflags gssapi`
+
+- if test -n "$KERBEROS_LIBS" && test -n "$KERBEROS_CFLAGS"; then
++ if test -n "$KERBEROS_LIBS" || test -n "$KERBEROS_CFLAGS"; then
+ found_kerberos=yes
+ PHP_EVAL_LIBLINE($KERBEROS_LIBS, $1)
+ PHP_EVAL_INCLINE($KERBEROS_CFLAGS)
--- /dev/null
+diff -urN php5.3-200803022130/ext/pgsql/php_pgsql.h mod/ext/pgsql/php_pgsql.h
+--- php5.3-200803022130/ext/pgsql/php_pgsql.h 2008-01-30 11:31:48.000000000 +0000
++++ mod/ext/pgsql/php_pgsql.h 2008-03-02 22:27:42.292062316 +0000
+@@ -41,7 +41,7 @@
+ #define PHP_PGSQL_API __declspec(dllimport)
+ #endif
+ #else
+-#include <libpq/libpq-fs.h>
++#include <postgresql/server/libpq/libpq-fs.h>
+ # if defined(__GNUC__) && __GNUC__ >= 4
+ # define PHP_PGSQL_API __attribute__ ((visibility("default")))
+ # else
--- /dev/null
+--- php/scripts/phpize.in.org 2008-06-16 10:03:28.882568639 +0200
++++ php/scripts/phpize.in 2008-06-16 10:04:37.424018256 +0200
+@@ -8,7 +8,7 @@
+ builddir="`pwd`"
+ SED="@SED@"
+
+-FILES_BUILD="mkdep.awk scan_makefile_in.awk shtool libtool.m4"
++FILES_BUILD="mkdep.awk scan_makefile_in.awk shtool libtool.m4 lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4"
+ FILES="acinclude.m4 Makefile.global config.sub config.guess ltmain.sh run-tests*.php"
+ CLEAN_FILES="$FILES *.o *.lo *.la .deps .libs/ build/ include/ modules/ install-sh \
+ mkinstalldirs missing config.nice config.sub config.guess configure configure.in \
+@@ -127,7 +127,7 @@
+
+ (cd "$phpdir" && cp $FILES_BUILD "$builddir"/build)
+ (cd "$phpdir" && cp $FILES "$builddir")
+- (cd "$builddir" && cat acinclude.m4 ./build/libtool.m4 > aclocal.m4)
++ (cd "$builddir" && cat acinclude.m4 ./build/{libtool,lt~obsolete,ltoptions,ltsugar,ltversion}.m4 > aclocal.m4)
+ }
+
+ phpize_replace_prefix()
--- /dev/null
+--- php-4.3.0/configure.in.orig Fri Dec 27 05:07:18 2002
++++ php-4.3.0/configure.in Thu Jan 2 20:34:43 2003
+@@ -288,7 +288,6 @@
+ PHP_CHECK_FUNC(htonl, socket)
+ PHP_CHECK_FUNC(gethostname, nsl)
+ PHP_CHECK_FUNC(gethostbyaddr, nsl)
+-PHP_CHECK_FUNC(yp_get_default_domain, nsl)
+
+ PHP_CHECK_FUNC(dlopen, dl)
+ if test "$ac_cv_func_dlopen" = "yes"; then
+--- php-5.2.0/acinclude.m4.orig 2006-12-22 21:52:13.766461055 +0100
++++ php-5.2.0/acinclude.m4 2006-12-22 21:52:37.159794165 +0100
+@@ -1740,18 +1740,18 @@
+ dnl Wrapper for AC_CHECK_LIB
+ dnl
+ AC_DEFUN([PHP_CHECK_LIBRARY], [
+- save_old_LDFLAGS=$LDFLAGS
++ save_old_LIBS=$LIBS
+ ac_stuff="$5"
+
+ save_ext_shared=$ext_shared
+ ext_shared=yes
+- PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
++ PHP_EVAL_LIBLINE([$]ac_stuff, LIBS)
+ AC_CHECK_LIB([$1],[$2],[
+- LDFLAGS=$save_old_LDFLAGS
++ LIBS=$save_old_LIBS
+ ext_shared=$save_ext_shared
+ $3
+ ],[
+- LDFLAGS=$save_old_LDFLAGS
++ LIBS=$save_old_LIBS
+ ext_shared=$save_ext_shared
+ unset ac_cv_lib_$1[]_$2
+ $4
--- /dev/null
+diff -ur php-5.3.0.org/configure.in php-5.3.0/configure.in
+--- php-5.3.0.org/configure.in 2009-06-26 17:44:18.000000000 +0200
++++ php-5.3.0/configure.in 2009-08-18 12:45:19.126841759 +0200
+@@ -1,7 +1,7 @@
+ ## $Id$ -*- autoconf -*-
+ dnl ## Process this file with autoconf to produce a configure script.
+
+-divert(1)
++divert(1001)
+
+ dnl ## Diversion 1 is the autoconf + automake setup phase. We also
+ dnl ## set the PHP version, deal with platform-specific compile
+@@ -308,7 +308,7 @@
+ sinclude(TSRM/tsrm.m4)
+
+
+-divert(2)
++divert(1002)
+
+ dnl ## Diversion 2 is where we set PHP-specific options and come up
+ dnl ## with reasonable default values for them. We check for pthreads here
+@@ -347,7 +347,7 @@
+ PTHREADS_FLAGS
+ fi
+
+-divert(3)
++divert(1003)
+
+ dnl ## In diversion 3 we check for compile-time options to the PHP
+ dnl ## core and how to deal with different system dependencies.
+@@ -702,7 +702,7 @@
+ PHP_CRYPT_R_STYLE
+ fi
+
+-divert(4)
++divert(1004)
+
+ dnl ## In diversion 4 we check user-configurable general settings.
+
+@@ -943,7 +943,7 @@
+ AC_MSG_RESULT([using system default])
+ fi
+
+-divert(5)
++divert(1005)
+
+ dnl ## In diversion 5 we check which extensions should be compiled.
+ dnl ## All of these are normally in the extension directories.
+diff -ur php-5.3.0.org/ext/standard/config.m4 php-5.3.0/ext/standard/config.m4
+--- php-5.3.0.org/ext/standard/config.m4 2009-01-12 00:37:16.000000000 +0100
++++ php-5.3.0/ext/standard/config.m4 2009-08-18 12:45:19.130174674 +0200
+@@ -1,6 +1,6 @@
+ dnl $Id$ -*- autoconf -*-
+
+-divert(3)dnl
++divert(1003)dnl
+
+ dnl
+ dnl Check if flush should be called explicitly after buffered io
+@@ -220,7 +220,7 @@
+ AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan)
+ AC_FUNC_FNMATCH
+
+-divert(5)dnl
++divert(1005)dnl
+
+ dnl
+ dnl Check if there is a support means of creating a new process
+diff -ur php-5.3.0.org/scripts/phpize.m4 php-5.3.0/scripts/phpize.m4
+--- php-5.3.0.org/scripts/phpize.m4 2009-06-02 21:54:03.000000000 +0200
++++ php-5.3.0/scripts/phpize.m4 2009-08-18 12:45:19.126841759 +0200
+@@ -1,6 +1,6 @@
+ dnl This file becomes configure.in for self-contained extensions.
+
+-divert(1)
++divert(1001)
+
+ AC_PREREQ(2.13)
+ AC_INIT(config.m4)
--- /dev/null
+--- php-5.2.0/ext/standard/mail.c 2006-12-01 14:20:27.881416250 +0100
++++ php-5.2.4/ext/standard/mail.c 2007-08-31 19:25:50.777713042 +0300
+@@ -21,6 +21,8 @@
+ #include <stdlib.h>
+ #include <ctype.h>
+ #include <stdio.h>
++#include <syslog.h>
++#include <string.h>
+ #include "php.h"
+ #include "ext/standard/info.h"
+
+@@ -35,6 +37,8 @@
+ #include "php_ini.h"
+ #include "safe_mode.h"
+ #include "exec.h"
++#include "zend_operators.h"
++#include "zend_globals.h"
+
+ #ifdef PHP_WIN32
+ #include "win32/sendmail.h"
+@@ -107,6 +111,18 @@
+ return;
+ }
+
++ /* search for To: and Subject: headers which should be specified in proper mail() parameters, not in additional headers */
++ if (headers != NULL) {
++ if (strncasecmp(headers, "to:", sizeof("to:") - 1) == 0 || strcasestr(headers, "\nto:")) {
++ php_error_docref(NULL TSRMLS_CC, E_WARNING, "To: headers aren't allowed in the additional_headers parameter. Use $to parameter for that. Mail not sent.");
++ RETURN_FALSE;
++ }
++ if (strncasecmp(headers, "subject:", sizeof("subject:") - 1) == 0 || strcasestr(headers, "\nsubject:")) {
++ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Subject: headers aren't allowed in the additional_headers parameter. Use $subject parameter for that. Mail not sent.");
++ RETURN_FALSE;
++ }
++ }
++
+ if (to_len > 0) {
+ to_r = estrndup(to, to_len);
+ for (; to_len; to_len--) {
+@@ -231,8 +247,42 @@
+ return 0;
+ }
+ #endif
+- fprintf(sendmail, "To: %s\n", to);
+- fprintf(sendmail, "Subject: %s\n", subject);
++ TSRMLS_FETCH();
++
++ if ((to != NULL) && (strlen(to)!=0)) {
++ fprintf(sendmail, "To: %s\n", to);
++ }
++ if ((subject != NULL) && (strlen(subject)!=0)) {
++ fprintf(sendmail, "Subject: %s\n", subject);
++ }
++
++ if (PG(http_globals)[TRACK_VARS_SERVER]) {
++ zval **remote_addr, **server_name, **server_port,
++ **script_name, **http_user_agent;
++
++ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "REMOTE_ADDR", sizeof("REMOTE_ADDR"), (void **) &remote_addr)==SUCCESS) {
++ convert_to_string_ex(remote_addr);
++ fprintf(sendmail, "HTTP-Posting-Client: %s\n", Z_STRVAL_PP(remote_addr));
++ }
++ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name)==SUCCESS) {
++ convert_to_string_ex(server_name);
++ fprintf(sendmail, "HTTP-Posting-URI: %s", Z_STRVAL_PP(server_name));
++ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_PORT", sizeof("SERVER_PORT"), (void **) &server_port)==SUCCESS) {
++ convert_to_string_ex(server_port);
++ fprintf(sendmail, ":%s", Z_STRVAL_PP(server_port));
++ }
++ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &script_name)==SUCCESS) {
++ convert_to_string_ex(script_name);
++ fprintf(sendmail, "%s", Z_STRVAL_PP(script_name));
++ }
++ fprintf(sendmail, "\n");
++ }
++ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &http_user_agent)==SUCCESS) {
++ convert_to_string_ex(http_user_agent);
++ fprintf(sendmail, "HTTP-Posting-User-Agent: %s\n", Z_STRVAL_PP(http_user_agent));
++ }
++ }
++
+ if (hdr != NULL) {
+ fprintf(sendmail, "%s\n", hdr);
+ }
--- /dev/null
+LoadModule php5_module modules/libphp5.so
+
+<IfModule mod_php5.c>
+ <Files *.php>
+ AddType application/x-httpd-php .php
+ </Files>
+ <Files *.php3>
+ AddType application/x-httpd-php .php3
+ </Files>
+ <Files *.php4>
+ AddType application/x-httpd-php .php4
+ </Files>
+ <Files *.php5>
+ AddType application/x-httpd-php .php5
+ </Files>
+ <Files *.inc>
+ AddType application/x-httpd-php .inc
+ </Files>
+ <Files *.phtml>
+ AddType application/x-httpd-php .phtml
+ </Files>
+</IfModule>
--- /dev/null
+--- php-5.2.5_p20080206.orig/ext/mysql/php_mysql.c 2008-02-06 14:22:57.652600900 +0100
++++ php-5.2.5_p20080206/ext/mysql/php_mysql.c 2008-02-06 14:24:40.216655403 +0100
+@@ -360,6 +360,7 @@
+ PHP_INI_ENTRY("mysql.default_port", NULL, PHP_INI_ALL, OnMySQLPort)
+ STD_PHP_INI_ENTRY("mysql.default_socket", NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_socket, zend_mysql_globals, mysql_globals)
+ STD_PHP_INI_ENTRY("mysql.connect_timeout", "60", PHP_INI_ALL, OnUpdateLong, connect_timeout, zend_mysql_globals, mysql_globals)
++ STD_PHP_INI_ENTRY("mysql.connect_charset", NULL, PHP_INI_ALL, OnUpdateString, connect_charset, zend_mysql_globals, mysql_globals)
+ STD_PHP_INI_BOOLEAN("mysql.trace_mode", "0", PHP_INI_ALL, OnUpdateLong, trace_mode, zend_mysql_globals, mysql_globals)
+ PHP_INI_END()
+ /* }}} */
+@@ -376,6 +377,7 @@
+ mysql_globals->connect_errno = 0;
+ mysql_globals->connect_error = NULL;
+ mysql_globals->connect_timeout = 0;
++ mysql_globals->connect_charset = NULL;
+ mysql_globals->trace_mode = 0;
+ mysql_globals->result_allocated = 0;
+ }
+@@ -515,6 +517,7 @@
+ {
+ char *user=NULL, *passwd=NULL, *host_and_port=NULL, *socket=NULL, *tmp=NULL, *host=NULL;
+ int user_len, passwd_len, host_len;
++ char *connect_charset=NULL;
+ char *hashed_details=NULL;
+ int hashed_details_length, port = MYSQL_PORT;
+ int client_flags = 0;
+@@ -527,6 +530,7 @@
+
+
+ connect_timeout = MySG(connect_timeout);
++ connect_charset = MySG(connect_charset);
+
+ socket = MySG(default_socket);
+
+--- php-5.3.1/ext/mysql/php_mysql.c~ 2010-02-20 00:51:52.000000000 +0200
++++ php-5.3.1/ext/mysql/php_mysql.c 2010-02-20 00:55:43.475653264 +0200
+@@ -777,6 +777,10 @@
+ if (connect_timeout != -1) {
+ mysql_options(mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
+ }
++
++ if (connect_charset != NULL)
++ mysql_options(mysql->conn, MYSQL_SET_CHARSET_NAME, connect_charset);
++
+ #ifndef MYSQL_USE_MYSQLND
+ if (mysql_real_connect(mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL)
+ #else
+@@ -826,6 +830,8 @@
+ #endif
+ if (mysql_ping(mysql->conn)) {
+ if (mysql_errno(mysql->conn) == 2006) {
++ if (connect_charset != NULL)
++ mysql_options(mysql->conn, MYSQL_SET_CHARSET_NAME, connect_charset);
+ #ifndef MYSQL_USE_MYSQLND
+ if (mysql_real_connect(mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL)
+ #else
+@@ -898,6 +904,9 @@
+ if (connect_timeout != -1)
+ mysql_options(mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
+
++ if (connect_charset != NULL)
++ mysql_options(mysql->conn, MYSQL_SET_CHARSET_NAME, connect_charset);
++
+ #ifndef MYSQL_USE_MYSQLND
+ if (mysql_real_connect(mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL)
+ #else
+--- php-5.2.5_p20080206.orig/ext/mysql/php_mysql_structs.h 2008-02-06 14:22:57.510605687 +0100
++++ php-5.2.5_p20080206/ext/mysql/php_mysql_structs.h 2008-02-06 14:23:27.764590355 +0100
+@@ -103,6 +103,7 @@
+ long default_port;
+ char *default_host, *default_user, *default_password;
+ char *default_socket;
++ char *connect_charset;
+ char *connect_error;
+ long connect_errno;
+ long connect_timeout;
--- /dev/null
+--- php-5.3.6/ext/mysql/php_mysql.c~ 2011-04-13 20:47:29.263652096 +0200
++++ php-5.3.6/ext/mysql/php_mysql.c 2011-04-13 20:48:30.206453191 +0200
+@@ -706,7 +706,7 @@
+
+ #if !defined(MYSQL_USE_MYSQLND)
+ if ((MYSQL_VERSION_ID / 100) != (mysql_get_client_version() / 100)) {
+- php_error_docref(NULL TSRMLS_CC, E_WARNING,
++ php_error_docref(NULL TSRMLS_CC, E_NOTICE,
+ "Headers and client library minor version mismatch. Headers:%d Library:%ld",
+ MYSQL_VERSION_ID, mysql_get_client_version());
+ }
+--- php-5.3.6/ext/mysqli/mysqli_nonapi.c~ 2011-04-13 20:47:29.273652556 +0200
++++ php-5.3.6/ext/mysqli/mysqli_nonapi.c 2011-04-13 20:48:41.070285840 +0200
+@@ -75,7 +75,7 @@
+
+ #if !defined(MYSQL_USE_MYSQLND)
+ if ((MYSQL_VERSION_ID / 100) != (mysql_get_client_version() / 100)) {
+- php_error_docref(NULL TSRMLS_CC, E_WARNING,
++ php_error_docref(NULL TSRMLS_CC, E_NOTICE,
+ "Headers and client library minor version mismatch. Headers:%d Library:%ld",
+ MYSQL_VERSION_ID, mysql_get_client_version());
+ }
--- /dev/null
+--- php-5.3.1/ext/mysqli/mysqli.c~ 2010-02-20 00:58:34.000000000 +0200
++++ php-5.3.1/ext/mysqli/mysqli.c 2010-02-20 01:00:22.459111311 +0200
+@@ -602,6 +602,7 @@
+ #else
+ STD_PHP_INI_ENTRY("mysqli.default_socket", NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_socket, zend_mysqli_globals, mysqli_globals)
+ #endif
++ STD_PHP_INI_ENTRY("mysqli.connect_charset", NULL, PHP_INI_ALL, OnUpdateString, connect_charset, zend_mysqli_globals, mysqli_globals)
+ STD_PHP_INI_BOOLEAN("mysqli.reconnect", "0", PHP_INI_SYSTEM, OnUpdateLong, reconnect, zend_mysqli_globals, mysqli_globals)
+ STD_PHP_INI_BOOLEAN("mysqli.allow_local_infile", "1", PHP_INI_SYSTEM, OnUpdateLong, allow_local_infile, zend_mysqli_globals, mysqli_globals)
+ #ifdef MYSQLI_USE_MYSQLND
+@@ -475,6 +476,7 @@
+ mysqli_globals->default_user = NULL;
+ mysqli_globals->default_pw = NULL;
+ mysqli_globals->default_socket = NULL;
++ mysqli_globals->connect_charset = NULL;
+ mysqli_globals->reconnect = 0;
+ mysqli_globals->report_mode = 0;
+ mysqli_globals->report_ht = 0;
+--- php-5.3.4/ext/mysqli/mysqli_nonapi.c~ 2010-12-12 23:07:03.000000000 +0200
++++ php-5.3.4/ext/mysqli/mysqli_nonapi.c 2010-12-12 23:07:36.497424912 +0200
+@@ -61,7 +61,7 @@
+ MY_MYSQL *mysql = NULL;
+ MYSQLI_RESOURCE *mysqli_resource = NULL;
+ zval *object = getThis();
+- char *hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL;
++ char *hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL, *connect_charset=NULL;
+ int hostname_len = 0, username_len = 0, passwd_len = 0, dbname_len = 0, socket_len = 0;
+ zend_bool persistent = FALSE;
+ long port = 0, flags = 0;
+@@ -241,6 +241,12 @@
+ }
+ #endif
+
++ connect_charset = MyG(connect_charset);
++
++ if (connect_charset != NULL) {
++ mysql_options(mysql->mysql, MYSQL_SET_CHARSET_NAME, connect_charset);
++ }
++
+ #if !defined(MYSQLI_USE_MYSQLND)
+ if (mysql_real_connect(mysql->mysql, hostname, username, passwd, dbname, port, socket, CLIENT_MULTI_RESULTS) == NULL)
+ #else
+--- php-5.3.1/ext/mysqli/php_mysqli_structs.h~ 2009-10-14 16:51:25.000000000 +0300
++++ php-5.3.1/ext/mysqli/php_mysqli_structs.h 2010-02-20 01:04:56.512214846 +0200
+@@ -358,6 +358,7 @@
+ char *default_user;
+ char *default_socket;
+ char *default_pw;
++ char *connect_charset;
+ long reconnect;
+ long allow_local_infile;
+ long strict;
--- /dev/null
+diff -ur php5.3-200807242030/configure.in mod/configure.in
+--- php5.3-200807242030/configure.in 2008-07-21 10:34:20.000000000 +0000
++++ mod/configure.in 2008-07-25 07:34:45.430571275 +0000
+@@ -1385,7 +1385,7 @@
+ fi;
+
+ all_targets="$lcov_target \$(OVERALL_TARGET) \$(PHP_MODULES) \$(PHP_ZEND_EX) \$(PHP_CLI_TARGET) $pharcmd"
+-install_targets="$install_modules install-build install-headers install-programs $install_pear $pharcmd_install"
++install_targets="$install_modules install-build install-headers install-programs $pharcmd_install"
+
+ case $PHP_SAPI in
+ cli)
--- /dev/null
+diff -urBb php-5.1.0RC1.org/sapi/apache2handler/config.m4 php-5.1.0RC1/sapi/apache2handler/config.m4
+--- php-5.1.0RC1.org/sapi/apache2handler/config.m4 2005-08-05 10:14:54.000000000 +0200
++++ php-5.1.0RC1/sapi/apache2handler/config.m4 2005-08-25 15:09:38.486655320 +0200
+@@ -58,9 +58,9 @@
+
+ # Test that we're trying to configure with apache 2.x
+ PHP_AP_EXTRACT_VERSION($APXS_HTTPD)
+- if test "$APACHE_VERSION" -le 2000000; then
++ if test "$APACHE_VERSION" -gt 0 -a "$APACHE_VERSION" -le 2000000; then
+ AC_MSG_ERROR([You have enabled Apache 2 support while your server is Apache 1.3. Please use the appropiate switch --with-apxs (without the 2)])
+- elif test "$APACHE_VERSION" -lt 2000044; then
++ elif test "$APACHE_VERSION" -gt 0 -a "$APACHE_VERSION" -lt 2000044; then
+ AC_MSG_ERROR([Please note that Apache version >= 2.0.44 is required])
+ fi
+
--- /dev/null
+--- php-5.3.3/ext/oci8/config.m4.orig 2010-06-25 23:18:09.000000000 +0200
++++ php-5.3.3/ext/oci8/config.m4 2010-09-10 19:37:23.484315002 +0200
+@@ -304,6 +304,9 @@
+
+ AC_MSG_CHECKING([Oracle Instant Client SDK header directory])
+
++ dnl Header directory for Instant Client SDK PLD RPM install
++ OCISDKPLDINC=$PHP_OCI8_INSTANT_CLIENT/../include/oracle/client
++
+ dnl Header directory for Instant Client SDK RPM install
+ OCISDKRPMINC=`echo "$PHP_OCI8_INSTANT_CLIENT" | $PHP_OCI8_SED -e 's!^/usr/lib/oracle/\(.*\)/client\('${PHP_OCI8_IC_LIBDIR_SUFFIX}'\)*/lib[/]*$!/usr/include/oracle/\1/client\2!'`
+
+@@ -313,7 +316,11 @@
+ dnl Header directory for manual installation
+ OCISDKMANINC=`echo "$PHP_OCI8_INSTANT_CLIENT" | $PHP_OCI8_SED -e 's!\(.*\)/lib[/]*$!\1/include!'`
+
+- if test -f "$OCISDKRPMINC/oci.h"; then
++ if test -f "$OCISDKPLDINC/oci.h"; then
++ AC_MSG_RESULT($OCISDKPLDINC)
++ PHP_ADD_INCLUDE($OCISDKPLDINC)
++ OCI8INCDIR=$OCISDKPLDINC
++ elif test -f "$OCISDKRPMINC/oci.h"; then
+ AC_MSG_RESULT($OCISDKRPMINC)
+ PHP_ADD_INCLUDE($OCISDKRPMINC)
+ OCI8INCDIR=$OCISDKRPMINC
+--- php-5.3.3/ext/pdo_oci/config.m4~ 2010-02-04 02:12:14.000000000 +0100
++++ php-5.3.3/ext/pdo_oci/config.m4 2010-09-10 19:58:31.206315023 +0200
+@@ -6,8 +6,10 @@
+ AC_DEFUN([AC_PDO_OCI_VERSION],[
+ AC_MSG_CHECKING([Oracle version])
+ for OCI_VER in $SUPPORTED_LIB_VERS; do
+- if test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.$OCI_VER; then
++ if test -f $1/lib/libclntsh.$SHLIB_SUFFIX_NAME.$OCI_VER; then
+ PDO_OCI_VERSION="$OCI_VER"
++ elif test -f $1/libclntsh.$SHLIB_SUFFIX_NAME.$OCI_VER; then
++ PDO_OCI_VERSION="$OCI_VER"
+ fi
+ done
+ if test -z "$PDO_OCI_VERSION"; then
+@@ -86,6 +86,9 @@
+ elif test -f $PDO_OCI_IC_PREFIX/client/include/oci.h ; then
+ PHP_ADD_INCLUDE($PDO_OCI_IC_PREFIX/client/include)
+ AC_MSG_RESULT($PDO_OCI_IC_PREFIX/client/include)
++ elif test -f $PDO_OCI_IC_PREFIX/../include/oracle/client/oci.h ; then
++ PHP_ADD_INCLUDE($PDO_OCI_IC_PREFIX/../include/oracle/client)
++ AC_MSG_RESULT($PDO_OCI_IC_PREFIX/../include/oracle/client)
+ else
+ AC_MSG_ERROR([I'm too dumb to figure out where the include dir is in your Instant Client install])
+ fi
+@@ -103,7 +103,12 @@
+ else
+ AC_MSG_ERROR([I'm too dumb to figure out where the libraries are in your Instant Client install])
+ fi
+- PDO_OCI_VERSION="`echo $PDO_OCI_IC_VERS | cut -d. -f1-2`"
++ __PDO_OCI_VERSION="`echo $PDO_OCI_IC_VERS | cut -d. -f1-2`"
++ if test -n "$__PDO_OCI_VERSION" ; then
++ PDO_OCI_VERSION=$__PDO_OCI_VERSION
++ else
++ AC_PDO_OCI_VERSION($PDO_OCI_IC_PREFIX)
++ fi
+ else
+ AC_PDO_OCI_CHECK_LIB_DIR($PDO_OCI_DIR)
+
--- /dev/null
+This is damn ugly patch if you need to update it, see PHP_5_2 branch version to
+understand what this patch is supposed to do as in 5.3 the ini section is
+enabled only if mysqlnd driver is enabled which makes the contexts really
+small.
+
+--- php-5.3.1/ext/pdo_mysql/mysql_driver.c~ 2010-02-20 01:08:04.000000000 +0200
++++ php-5.3.1/ext/pdo_mysql/mysql_driver.c 2010-02-20 01:08:52.982186037 +0200
+@@ -436,6 +436,7 @@
+ pdo_mysql_db_handle *H;
+ int i, ret = 0;
+ char *host = NULL, *unix_socket = NULL;
++ char *connect_charset = NULL;
+ unsigned int port = 3306;
+ char *dbname;
+ struct pdo_data_src_parser vars[] = {
+@@ -731,6 +731,12 @@
+ password_len = strlen(dbh->password);
+ }
+
++ connect_charset = PDO_MYSQL_G(connect_charset);
++
++ if (connect_charset != NULL) {
++ mysql_options(H->server, MYSQL_SET_CHARSET_NAME, connect_charset);
++ }
++
+ if (mysqlnd_connect(H->server, host, dbh->username, dbh->password, password_len, dbname, dbname_len,
+ port, unix_socket, connect_opts, PDO_MYSQL_G(mysqlnd_thd_zval_cache) TSRMLS_CC) == NULL) {
+ #else
+--- php-5.3.3/ext/pdo_mysql/pdo_mysql.c~ 2010-07-24 19:23:14.000000000 +0300
++++ php-5.3.3/ext/pdo_mysql/pdo_mysql.c 2010-07-24 19:24:48.363581841 +0300
+@@ -56,6 +56,7 @@
+ #if PDO_DBG_ENABLED
+ STD_PHP_INI_ENTRY("pdo_mysql.debug", NULL, PHP_INI_SYSTEM, OnUpdateString, debug, zend_pdo_mysql_globals, pdo_mysql_globals)
+ #endif
++ STD_PHP_INI_ENTRY("pdo_mysql.connect_charset", NULL, PHP_INI_ALL, OnUpdateString, connect_charset, zend_pdo_mysql_globals, pdo_mysql_globals)
+ PHP_INI_END()
+ /* }}} */
+
+@@ -89,9 +90,7 @@
+ static PHP_MSHUTDOWN_FUNCTION(pdo_mysql)
+ {
+ php_pdo_unregister_driver(&pdo_mysql_driver);
+-#if PDO_USE_MYSQLND
+ UNREGISTER_INI_ENTRIES();
+-#endif
+
+ return SUCCESS;
+ }
+@@ -108,9 +107,7 @@
+
+ php_info_print_table_end();
+
+-#ifdef PDO_USE_MYSQLND
+ DISPLAY_INI_ENTRIES();
+-#endif
+ }
+ /* }}} */
+
+@@ -161,6 +161,7 @@
+ pdo_mysql_globals->debug = NULL; /* The actual string */
+ pdo_mysql_globals->dbg = NULL; /* The DBG object*/
+ #endif
++ pdo_mysql_globals->connect_charset = NULL;
+ }
+ /* }}} */
+
+--- php-5.3.2RC3/ext/pdo_mysql/php_pdo_mysql_int.h~ 2010-02-04 11:37:38.000000000 +0200
++++ php-5.3.2RC3/ext/pdo_mysql/php_pdo_mysql_int.h 2010-02-26 19:11:47.484055898 +0200
+@@ -69,6 +69,7 @@
+ char *debug; /* The actual string */
+ MYSQLND_DEBUG *dbg; /* The DBG object */
+ #endif
++ char *connect_charset;
+ #if defined(PHP_WIN32) && !PDO_DBG_ENABLED
+ /* dummy member so we get at least one member in the struct
+ * and avoids build errors.
--- /dev/null
+--- php-5.3.1/configure.in~ 2010-02-19 23:26:13.000000000 +0200
++++ php-5.3.1/configure.in 2010-02-19 23:27:58.273207305 +0200
+@@ -934,11 +934,6 @@
+ with_pear=no
+ fi
+
+-# If CLI is disabled -> disable PEAR
+-if test "$PHP_CLI" = "no"; then
+- with_pear=no
+-fi
+-
+ PHP_ARG_WITH(pear, [whether to install PEAR],
+ [ --with-pear=DIR Install PEAR in DIR [PREFIX/lib/php]
+ --without-pear Do not install PEAR], DEFAULT, yes)
+@@ -1023,11 +1023,11 @@
+ dnl
+ dnl PEAR dependancies
+ dnl
+- if test "$PHP_XML" = "no"; then
+- pear_error_msg="$pear_error_msg
+- PEAR requires XML to be enabled. Add --enable-xml to the configure line. (or --without-pear)"
+- fi
+-
++dnl if test "$PHP_XML" = "no"; then
++dnl pear_error_msg="$pear_error_msg
++dnl PEAR requires XML to be enabled. Add --enable-xml to the configure line. (or --without-pear)"
++dnl fi
++dnl
+ dnl
+ dnl if test "$PHP_XMLRPC" = "no"; then
+ dnl pear_error_msg="$pear_error_msg
+--- php-5.2.6/sapi/cli/config.m4~ 2008-11-16 18:35:31.000000000 +0200
++++ php-5.2.6/sapi/cli/config.m4 2008-11-20 19:04:12.585061299 +0200
+@@ -4,7 +4,7 @@
+
+ PHP_ARG_ENABLE(cli,,
+ [ --disable-cli Disable building CLI version of PHP
+- (this forces --without-pear)], yes, no)
++ ], yes, no)
+
+ AC_MSG_CHECKING(for CLI build)
+ if test "$PHP_CLI" != "no"; then
--- /dev/null
+diff -urN php-5.1.0RC1.org/sapi/cli/config.m4 php-5.1.0RC1/sapi/cli/config.m4
+--- php-5.1.0RC1.org/sapi/cli/config.m4 2005-08-25 19:54:02.051504000 +0200
++++ php-5.1.0RC1/sapi/cli/config.m4 2005-08-25 19:54:28.699452976 +0200
+@@ -29,7 +29,7 @@
+ BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -Lnetware -lphp5lib -o \$(SAPI_CLI_PATH)"
+ ;;
+ *)
+- BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) libphp_common.la \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)"
++ BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) libphp_common.la \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) \$(READLINE_SHARED_LIBADD) -o \$(SAPI_CLI_PATH)"
+ ;;
+ esac
+ INSTALL_CLI="\$(mkinstalldirs) \$(INSTALL_ROOT)\$(bindir); \$(INSTALL) -m 0755 \$(SAPI_CLI_PATH) \$(INSTALL_ROOT)\$(bindir)/\$(program_prefix)php\$(program_suffix)\$(EXEEXT)"
--- /dev/null
+--- php-5.3.0/main/php_ini.c 2009-07-06 17:36:45.529879052 +0200
++++ php-5.3.2/main/php_ini.c 2010-03-17 17:55:16.800313459 +0200
+@@ -358,6 +358,11 @@
+ }
+ /* }}} */
+
++static int php_csort(const struct dirent **a, const struct dirent **b)
++{
++ return strcmp((*a)->d_name,(*b)->d_name);
++}
++
+ /* {{{ php_init_config
+ */
+ int php_init_config(TSRMLS_D)
+@@ -480,6 +485,24 @@
+ }
+ }
+ }
++ /* Search (global) php.ini file in search path */
++ if (!fh.handle.fp) {
++ fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
++ if (fh.handle.fp) {
++ fh.filename = php_ini_opened_path;
++ PG(safe_mode) = safe_mode_state;
++ PG(open_basedir) = open_basedir;
++ fh.type = ZEND_HANDLE_FP;
++ zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC);
++ safe_mode_state = PG(safe_mode);
++ open_basedir = PG(open_basedir);
++ PG(safe_mode) = 0;
++ PG(open_basedir) = NULL;
++ fh.handle.fp = NULL;
++ efree(php_ini_opened_path);
++ fh.filename = php_ini_opened_path = NULL;
++ }
++ }
+
+ /* Otherwise search for php-%sapi-module-name%.ini file in search path */
+ if (!fh.handle.fp) {
+@@ -492,14 +515,6 @@
+ fh.filename = php_ini_opened_path;
+ }
+ }
+-
+- /* If still no ini file found, search for php.ini file in search path */
+- if (!fh.handle.fp) {
+- fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
+- if (fh.handle.fp) {
+- fh.filename = php_ini_opened_path;
+- }
+- }
+ }
+
+ if (free_ini_search_path) {
+@@ -610,12 +625,14 @@
+ zend_llist scanned_ini_list;
+ zend_llist_element *element;
+ int l, total_l = 0;
++ const char *fmt = "%s:" PHP_CONFIG_FILE_PATH "/%s.d";
+
+ /* List of found ini files */
+ zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
+
+ /* Split by paths_separator and load ini-files from all paths */
+- path_copy = estrdup(php_ini_scanned_path);
++ path_copy = emalloc(strlen(php_ini_scanned_path) + strlen(fmt) + strlen(sapi_module.name));
++ sprintf(path_copy, fmt, php_ini_scanned_path, sapi_module.name);
+ ini_path = php_strtok_r(path_copy, paths_separator, &last);
+
+ while (ini_path != NULL) {
+@@ -636,7 +653,7 @@
+ struct dirent **namelist;
+ int ini_path_len = strlen(ini_path);
+
+- if ((ndir = php_scandir(ini_path, &namelist, 0, php_alphasort)) > 0) {
++ if ((ndir = php_scandir(ini_path, &namelist, 0, php_csort)) > 0) {
+ memset(&fh2, 0, sizeof(fh2));
+
+ for (i = 0; i < ndir; i++) {
--- /dev/null
+--- php-5.1.6/acinclude.m4.orig 2006-11-21 10:43:13.179505000 +0100
++++ php-5.1.6/acinclude.m4 2006-11-21 10:55:32.479505000 +0100
+@@ -68,8 +68,8 @@
+ changequote({,})
+ ep_dir="`echo $1|$SED 's%/*[^/][^/]*/*$%%'`"
+ changequote([,])
+- ep_realdir="`(cd \"$ep_dir\" && pwd)`"
+- $2="$ep_realdir/`basename \"$1\"`"
++ ep_realdir="$(cd "$ep_dir" && pwd)"
++ $2="$ep_realdir/$(basename "$1")"
+ fi
+ ])
+
--- /dev/null
+--- php-5.2.4/Makefile.global~ 2007-08-31 19:13:58.000000000 +0300
++++ php-5.2.4/Makefile.global 2007-08-31 19:19:33.799017413 +0300
+@@ -13,8 +13,12 @@
+
+ build-modules: $(PHP_MODULES)
+
+-libphp$(PHP_MAJOR_VERSION).la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
+- $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
++libphp_common.la: $(PHP_GLOBAL_OBJS)
++ $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) -avoid-version $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ -release $(PHP_VERSION)
++ -@$(LIBTOOL) --silent --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1
++
++libphp$(PHP_MAJOR_VERSION).la: libphp_common.la $(PHP_SAPI_OBJS)
++ $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(phptempdir)/libphp_common.la $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
+ -@$(LIBTOOL) --silent --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1
+
+ libs/libphp$(PHP_MAJOR_VERSION).bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
+@@ -25,10 +29,10 @@
+ install-sapi: $(OVERALL_TARGET)
+ @echo "Installing PHP SAPI module: $(PHP_SAPI)"
+ -@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
+- -@if test ! -r $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME); then \
++ -@if test ! -r $(phptempdir)/libphp_common.$(SHLIB_DL_SUFFIX_NAME); then \
+ for i in 0.0.0 0.0 0; do \
+- if test -r $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME).$$i; then \
+- $(LN_S) $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME).$$i $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME); \
++ if test -r $(phptempdir)/libphp_common.$(SHLIB_DL_SUFFIX_NAME).$$i; then \
++ $(LN_S) $(phptempdir)/libphp_common.$(SHLIB_DL_SUFFIX_NAME).$$i $(phptempdir)/libphp_common.$(SHLIB_DL_SUFFIX_NAME); \
+ break; \
+ fi; \
+ done; \
+--- php-5.0.0.org/sapi/cgi/config9.m4 2004-07-25 22:41:53.698171496 +0200
++++ php-5.0.0/sapi/cgi/config9.m4 2004-07-25 22:42:04.894469400 +0200
+@@ -156,7 +156,7 @@
+ BUILD_CGI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_SAPI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
+ ;;
+ *)
+- BUILD_CGI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_SAPI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
++ BUILD_CGI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) libphp_common.la \$(PHP_SAPI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
+ ;;
+ esac
+
+--- php-5.0.0.org/sapi/cgi/Makefile.frag 2004-07-25 22:41:53.696171800 +0200
++++ php-5.0.0/sapi/cgi/Makefile.frag 2004-07-25 22:42:04.895469248 +0200
+@@ -1,2 +1,2 @@
+-$(SAPI_CGI_PATH): $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
++$(SAPI_CGI_PATH): libphp_common.la $(PHP_SAPI_OBJS)
+ $(BUILD_CGI)
+--- php-5.0.0.org/sapi/cli/config.m4 2004-07-25 22:41:53.700171192 +0200
++++ php-5.0.0/sapi/cli/config.m4 2004-07-25 22:42:04.895469248 +0200
+@@ -27,7 +27,7 @@
+ BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)"
+ ;;
+ *)
+- BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)"
++ BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) libphp_common.la \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)"
+ ;;
+ esac
+ INSTALL_CLI="\$(mkinstalldirs) \$(INSTALL_ROOT)\$(bindir); \$(INSTALL) -m 0755 \$(SAPI_CLI_PATH) \$(INSTALL_ROOT)\$(bindir)/\$(program_prefix)php\$(program_suffix)"
+--- php-5.0.0.org/sapi/cli/Makefile.frag 2004-07-25 22:41:53.699171344 +0200
++++ php-5.0.0/sapi/cli/Makefile.frag 2004-07-25 22:42:04.896469096 +0200
+@@ -1,6 +1,6 @@
+ cli: $(SAPI_CLI_PATH)
+
+-$(SAPI_CLI_PATH): $(PHP_GLOBAL_OBJS) $(PHP_CLI_OBJS)
++$(SAPI_CLI_PATH): libphp_common.la $(PHP_CLI_OBJS)
+ $(BUILD_CLI)
+
+ install-cli: $(SAPI_CLI_PATH)
--- /dev/null
+--- php-5.3.0/ext/session/mod_files.c~ 2009-05-18 18:10:09.000000000 +0200
++++ php-5.3.0/ext/session/mod_files.c 2009-08-07 08:41:53.029357590 +0200
+@@ -217,7 +217,6 @@
+
+ dir = opendir(dirname);
+ if (!dir) {
+- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "ps_files_cleanup_dir: opendir(%s) failed: %s (%d)", dirname, strerror(errno), errno);
+ return (0);
+ }
+
--- /dev/null
+--- php-5.3.1/acinclude.m4~ 2009-11-26 00:49:53.000000000 +0200
++++ php-5.3.1/acinclude.m4 2009-11-26 00:51:11.466867803 +0200
+@@ -2582,7 +2582,11 @@
+ dnl version for apache1/2.
+ dnl
+ AC_DEFUN([PHP_AP_EXTRACT_VERSION],[
+- ac_output=`$1 -v 2>&1 | grep version`
++ if test "$with_apache_version" != "no"; then
++ ac_output="foo bar baz $with_apache_version"
++ else
++ ac_output=`$1 -v 2>&1 | grep version`
++ fi
+ ac_IFS=$IFS
+ IFS="- /.
+ "
--- /dev/null
+
+Add support for use of the system timezone database, rather
+than embedding a copy. Discussed upstream but was not desired.
+
+History:
+r7: improve check for valid timezone id to exclude directories
+r6: fix fd leak in r5, fix country code/BC flag use in
+ timezone_identifiers_list() using system db,
+ fix use of PECL timezonedb to override system db,
+r5: reverts addition of "System/Localtime" fake tzname.
+ updated for 5.3.0, parses zone.tab to pick up mapping between
+ timezone name, country code and long/lat coords
+r4: added "System/Localtime" tzname which uses /etc/localtime
+r3: fix a crash if /usr/share/zoneinfo doesn't exist (Raphael Geissert)
+r2: add filesystem trawl to set up name alias index
+r1: initial revision
+
+--- php-5.3.1/ext/date/lib/parse_tz.c.systzdata
++++ php-5.3.1/ext/date/lib/parse_tz.c
+@@ -20,6 +20,16 @@
+
+ #include "timelib.h"
+
++#ifdef HAVE_SYSTEM_TZDATA
++#include <sys/mman.h>
++#include <sys/stat.h>
++#include <limits.h>
++#include <fcntl.h>
++#include <unistd.h>
++
++#include "php_scandir.h"
++#endif
++
+ #include <stdio.h>
+
+ #ifdef HAVE_LOCALE_H
+@@ -31,7 +41,12 @@
+ #else
+ #include <strings.h>
+ #endif
++
++#ifndef HAVE_SYSTEM_TZDATA
+ #include "timezonedb.h"
++#endif
++
++#include <ctype.h>
+
+ #if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__))
+ # if defined(__LITTLE_ENDIAN__)
+@@ -51,9 +66,14 @@
+
+ static void read_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
+ {
+- /* skip ID */
+- *tzf += 4;
+-
++ if (memcmp(tzf, "TZif", 4) == 0) {
++ *tzf += 20;
++ return;
++ }
++
++ /* skip ID */
++ *tzf += 4;
++
+ /* read BC flag */
+ tz->bc = (**tzf == '\1');
+ *tzf += 1;
+@@ -253,7 +273,397 @@ void timelib_dump_tzinfo(timelib_tzinfo
+ }
+ }
+
+-static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const timelib_tzdb *tzdb)
++#ifdef HAVE_SYSTEM_TZDATA
++
++#ifdef HAVE_SYSTEM_TZDATA_PREFIX
++#define ZONEINFO_PREFIX HAVE_SYSTEM_TZDATA_PREFIX
++#else
++#define ZONEINFO_PREFIX "/usr/share/zoneinfo"
++#endif
++
++/* System timezone database pointer. */
++static const timelib_tzdb *timezonedb_system = NULL;
++
++/* Hash table entry for the cache of the zone.tab mapping table. */
++struct location_info {
++ char code[2];
++ double latitude, longitude;
++ char name[64];
++ char *comment;
++ struct location_info *next;
++};
++
++/* Cache of zone.tab. */
++static struct location_info **system_location_table;
++
++/* Size of the zone.tab hash table; a random-ish prime big enough to
++ * prevent too many collisions. */
++#define LOCINFO_HASH_SIZE (1021)
++
++static uint32_t tz_hash(const char *str)
++{
++ const unsigned char *p = (const unsigned char *)str;
++ uint32_t hash = 5381;
++ int c;
++
++ while ((c = *p++) != '\0') {
++ hash = (hash << 5) ^ hash ^ c;
++ }
++
++ return hash % LOCINFO_HASH_SIZE;
++}
++
++/* Parse an ISO-6709 date as used in zone.tab. Returns end of the
++ * parsed string on success, or NULL on parse error. On success,
++ * writes the parsed number to *result. */
++static char *parse_iso6709(char *p, double *result)
++{
++ double v, sign;
++ char *pend;
++ size_t len;
++
++ if (*p == '+')
++ sign = 1.0;
++ else if (*p == '-')
++ sign = -1.0;
++ else
++ return NULL;
++
++ p++;
++ for (pend = p; *pend >= '0' && *pend <= '9'; pend++)
++ ;;
++
++ /* Annoying encoding used by zone.tab has no decimal point, so use
++ * the length to determine the format:
++ *
++ * 4 = DDMM
++ * 5 = DDDMM
++ * 6 = DDMMSS
++ * 7 = DDDMMSS
++ */
++ len = pend - p;
++ if (len < 4 || len > 7) {
++ return NULL;
++ }
++
++ /* p => [D]DD */
++ v = (p[0] - '0') * 10.0 + (p[1] - '0');
++ p += 2;
++ if (len == 5 || len == 7)
++ v = v * 10.0 + (*p++ - '0');
++ /* p => MM[SS] */
++ v += (10.0 * (p[0] - '0')
++ + p[1] - '0') / 60.0;
++ p += 2;
++ /* p => [SS] */
++ if (len > 5) {
++ v += (10.0 * (p[0] - '0')
++ + p[1] - '0') / 3600.0;
++ p += 2;
++ }
++
++ /* Round to five decimal place, not because it's a good idea,
++ * but, because the builtin data uses rounded data, so, match
++ * that. */
++ *result = round(v * sign * 100000.0) / 100000.0;
++
++ return p;
++}
++
++/* This function parses the zone.tab file to build up the mapping of
++ * timezone to country code and geographic location, and returns a
++ * hash table. The hash table is indexed by the function:
++ *
++ * tz_hash(timezone-name)
++ */
++static struct location_info **create_location_table(void)
++{
++ struct location_info **li, *i;
++ char zone_tab[PATH_MAX];
++ char line[512];
++ FILE *fp;
++
++ strncpy(zone_tab, ZONEINFO_PREFIX "/zone.tab", sizeof zone_tab);
++
++ fp = fopen(zone_tab, "r");
++ if (!fp) {
++ return NULL;
++ }
++
++ li = calloc(LOCINFO_HASH_SIZE, sizeof *li);
++
++ while (fgets(line, sizeof line, fp)) {
++ char *p = line, *code, *name, *comment;
++ uint32_t hash;
++ double latitude, longitude;
++
++ while (isspace(*p))
++ p++;
++
++ if (*p == '#' || *p == '\0' || *p == '\n')
++ continue;
++
++ if (!isalpha(p[0]) || !isalpha(p[1]) || p[2] != '\t')
++ continue;
++
++ /* code => AA */
++ code = p;
++ p[2] = 0;
++ p += 3;
++
++ /* coords => [+-][D]DDMM[SS][+-][D]DDMM[SS] */
++ p = parse_iso6709(p, &latitude);
++ if (!p) {
++ continue;
++ }
++ p = parse_iso6709(p, &longitude);
++ if (!p) {
++ continue;
++ }
++
++ if (!p || *p != '\t') {
++ continue;
++ }
++
++ /* name = string */
++ name = ++p;
++ while (*p != '\t' && *p && *p != '\n')
++ p++;
++
++ *p++ = '\0';
++
++ /* comment = string */
++ comment = p;
++ while (*p != '\t' && *p && *p != '\n')
++ p++;
++
++ if (*p == '\n' || *p == '\t')
++ *p = '\0';
++
++ hash = tz_hash(name);
++ i = malloc(sizeof *i);
++ memcpy(i->code, code, 2);
++ strncpy(i->name, name, sizeof i->name);
++ i->comment = strdup(comment);
++ i->longitude = longitude;
++ i->latitude = latitude;
++ i->next = li[hash];
++ li[hash] = i;
++ /* printf("%s [%u, %f, %f]\n", name, hash, latitude, longitude); */
++ }
++
++ fclose(fp);
++
++ return li;
++}
++
++/* Return location info from hash table, using given timezone name.
++ * Returns NULL if the name could not be found. */
++const struct location_info *find_zone_info(struct location_info **li,
++ const char *name)
++{
++ uint32_t hash = tz_hash(name);
++ const struct location_info *l;
++
++ if (!li) {
++ return NULL;
++ }
++
++ for (l = li[hash]; l; l = l->next) {
++ if (strcasecmp(l->name, name) == 0)
++ return l;
++ }
++
++ return NULL;
++}
++
++/* Filter out some non-tzdata files and the posix/right databases, if
++ * present. */
++static int index_filter(const struct dirent *ent)
++{
++ return strcmp(ent->d_name, ".") != 0
++ && strcmp(ent->d_name, "..") != 0
++ && strcmp(ent->d_name, "posix") != 0
++ && strcmp(ent->d_name, "posixrules") != 0
++ && strcmp(ent->d_name, "right") != 0
++ && strstr(ent->d_name, ".tab") == NULL;
++}
++
++static int sysdbcmp(const void *first, const void *second)
++{
++ const timelib_tzdb_index_entry *alpha = first, *beta = second;
++
++ return strcmp(alpha->id, beta->id);
++}
++
++
++/* Create the zone identifier index by trawling the filesystem. */
++static void create_zone_index(timelib_tzdb *db)
++{
++ size_t dirstack_size, dirstack_top;
++ size_t index_size, index_next;
++ timelib_tzdb_index_entry *db_index;
++ char **dirstack;
++
++ /* LIFO stack to hold directory entries to scan; each slot is a
++ * directory name relative to the zoneinfo prefix. */
++ dirstack_size = 32;
++ dirstack = malloc(dirstack_size * sizeof *dirstack);
++ dirstack_top = 1;
++ dirstack[0] = strdup("");
++
++ /* Index array. */
++ index_size = 64;
++ db_index = malloc(index_size * sizeof *db_index);
++ index_next = 0;
++
++ do {
++ struct dirent **ents;
++ char name[PATH_MAX], *top;
++ int count;
++
++ /* Pop the top stack entry, and iterate through its contents. */
++ top = dirstack[--dirstack_top];
++ snprintf(name, sizeof name, ZONEINFO_PREFIX "/%s", top);
++
++ count = php_scandir(name, &ents, index_filter, php_alphasort);
++
++ while (count > 0) {
++ struct stat st;
++ const char *leaf = ents[count - 1]->d_name;
++
++ snprintf(name, sizeof name, ZONEINFO_PREFIX "/%s/%s",
++ top, leaf);
++
++ if (strlen(name) && stat(name, &st) == 0) {
++ /* Name, relative to the zoneinfo prefix. */
++ const char *root = top;
++
++ if (root[0] == '/') root++;
++
++ snprintf(name, sizeof name, "%s%s%s", root,
++ *root ? "/": "", leaf);
++
++ if (S_ISDIR(st.st_mode)) {
++ if (dirstack_top == dirstack_size) {
++ dirstack_size *= 2;
++ dirstack = realloc(dirstack,
++ dirstack_size * sizeof *dirstack);
++ }
++ dirstack[dirstack_top++] = strdup(name);
++ }
++ else {
++ if (index_next == index_size) {
++ index_size *= 2;
++ db_index = realloc(db_index,
++ index_size * sizeof *db_index);
++ }
++
++ db_index[index_next++].id = strdup(name);
++ }
++ }
++
++ free(ents[--count]);
++ }
++
++ if (count != -1) free(ents);
++ free(top);
++ } while (dirstack_top);
++
++ qsort(db_index, index_next, sizeof *db_index, sysdbcmp);
++
++ db->index = db_index;
++ db->index_size = index_next;
++
++ free(dirstack);
++}
++
++#define FAKE_HEADER "1234\0??\1??"
++#define FAKE_UTC_POS (7 - 4)
++
++/* Create a fake data segment for database 'sysdb'. */
++static void fake_data_segment(timelib_tzdb *sysdb,
++ struct location_info **info)
++{
++ size_t n;
++ char *data, *p;
++
++ data = malloc(3 * sysdb->index_size + 7);
++
++ p = mempcpy(data, FAKE_HEADER, sizeof(FAKE_HEADER) - 1);
++
++ for (n = 0; n < sysdb->index_size; n++) {
++ const struct location_info *li;
++ timelib_tzdb_index_entry *ent;
++
++ ent = (timelib_tzdb_index_entry *)&sysdb->index[n];
++
++ /* Lookup the timezone name in the hash table. */
++ if (strcmp(ent->id, "UTC") == 0) {
++ ent->pos = FAKE_UTC_POS;
++ continue;
++ }
++
++ li = find_zone_info(info, ent->id);
++ if (li) {
++ /* If found, append the BC byte and the
++ * country code; set the position for this
++ * section of timezone data. */
++ ent->pos = (p - data) - 4;
++ *p++ = '\1';
++ *p++ = li->code[0];
++ *p++ = li->code[1];
++ }
++ else {
++ /* If not found, the timezone data can
++ * point at the header. */
++ ent->pos = 0;
++ }
++ }
++
++ sysdb->data = (unsigned char *)data;
++}
++
++/* Returns true if the passed-in stat structure describes a
++ * probably-valid timezone file. */
++static int is_valid_tzfile(const struct stat *st)
++{
++ return S_ISREG(st->st_mode) && st->st_size > 20;
++}
++
++/* Return the mmap()ed tzfile if found, else NULL. On success, the
++ * length of the mapped data is placed in *length. */
++static char *map_tzfile(const char *timezone, size_t *length)
++{
++ char fname[PATH_MAX];
++ struct stat st;
++ char *p;
++ int fd;
++
++ if (timezone[0] == '\0' || strstr(timezone, "..") != NULL) {
++ return NULL;
++ }
++
++ snprintf(fname, sizeof fname, ZONEINFO_PREFIX "/%s", timezone);
++
++ fd = open(fname, O_RDONLY);
++ if (fd == -1) {
++ return NULL;
++ } else if (fstat(fd, &st) != 0 || !is_valid_tzfile(&st)) {
++ close(fd);
++ return NULL;
++ }
++
++ *length = st.st_size;
++ p = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
++ close(fd);
++
++ return p != MAP_FAILED ? p : NULL;
++}
++
++#endif
++
++static int inmem_seek_to_tz_position(const unsigned char **tzf, char *timezone, const timelib_tzdb *tzdb)
+ {
+ int left = 0, right = tzdb->index_size - 1;
+ #ifdef HAVE_SETLOCALE
+@@ -292,36 +702,125 @@ static int seek_to_tz_position(const uns
+ return 0;
+ }
+
++static int seek_to_tz_position(const unsigned char **tzf, char *timezone,
++ char **map, size_t *maplen,
++ const timelib_tzdb *tzdb)
++{
++ if (tzdb == timezonedb_system) {
++ char *orig;
++
++ orig = map_tzfile(timezone, maplen);
++ if (orig == NULL) {
++ return 0;
++ }
++
++ (*tzf) = (unsigned char *)orig ;
++ *map = orig;
++
++ return 1;
++ }
++ else {
++ return inmem_seek_to_tz_position(tzf, timezone, tzdb);
++ }
++}
++
+ const timelib_tzdb *timelib_builtin_db(void)
+ {
++#ifdef HAVE_SYSTEM_TZDATA
++ if (timezonedb_system == NULL) {
++ timelib_tzdb *tmp = malloc(sizeof *tmp);
++
++ tmp->version = "0.system";
++ tmp->data = NULL;
++ create_zone_index(tmp);
++ system_location_table = create_location_table();
++ fake_data_segment(tmp, system_location_table);
++ timezonedb_system = tmp;
++ }
++
++
++ return timezonedb_system;
++#else
+ return &timezonedb_builtin;
++#endif
+ }
+
+ const timelib_tzdb_index_entry *timelib_timezone_builtin_identifiers_list(int *count)
+ {
++#ifdef HAVE_SYSTEM_TZDATA
++ *count = timezonedb_system->index_size;
++ return timezonedb_system->index;
++#else
+ *count = sizeof(timezonedb_idx_builtin) / sizeof(*timezonedb_idx_builtin);
+ return timezonedb_idx_builtin;
++#endif
+ }
+
+ int timelib_timezone_id_is_valid(char *timezone, const timelib_tzdb *tzdb)
+ {
+ const unsigned char *tzf;
+- return (seek_to_tz_position(&tzf, timezone, tzdb));
++
++#ifdef HAVE_SYSTEM_TZDATA
++ if (tzdb == timezonedb_system) {
++ char fname[PATH_MAX];
++ struct stat st;
++
++ if (timezone[0] == '\0' || strstr(timezone, "..") != NULL) {
++ return 0;
++ }
++
++ snprintf(fname, sizeof fname, ZONEINFO_PREFIX "/%s", timezone);
++
++ return stat(fname, &st) == 0 && is_valid_tzfile(&st);
++ }
++#endif
++
++ return (inmem_seek_to_tz_position(&tzf, timezone, tzdb));
+ }
+
+ timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb)
+ {
+ const unsigned char *tzf;
++ char *memmap = NULL;
++ size_t maplen;
+ timelib_tzinfo *tmp;
+
+- if (seek_to_tz_position(&tzf, timezone, tzdb)) {
++ if (seek_to_tz_position(&tzf, timezone, &memmap, &maplen, tzdb)) {
+ tmp = timelib_tzinfo_ctor(timezone);
+
+ read_preamble(&tzf, tmp);
+ read_header(&tzf, tmp);
+ read_transistions(&tzf, tmp);
+ read_types(&tzf, tmp);
+- read_location(&tzf, tmp);
++
++#ifdef HAVE_SYSTEM_TZDATA
++ if (memmap) {
++ const struct location_info *li;
++
++ /* TZif-style - grok the location info from the system database,
++ * if possible. */
++
++ if ((li = find_zone_info(system_location_table, timezone)) != NULL) {
++ tmp->location.comments = strdup(li->comment);
++ strncpy(tmp->location.country_code, li->code, 2);
++ tmp->location.longitude = li->longitude;
++ tmp->location.latitude = li->latitude;
++ tmp->bc = 1;
++ }
++ else {
++ strcpy(tmp->location.country_code, "??");
++ tmp->bc = 0;
++ tmp->location.comments = strdup("");
++ }
++
++ /* Now done with the mmap segment - discard it. */
++ munmap(memmap, maplen);
++#endif
++ }
++ else {
++ /* PHP-style - use the embedded info. */
++ read_location(&tzf, tmp);
++ }
+ } else {
+ tmp = NULL;
+ }
+--- php-5.3.1/ext/date/lib/timelib.m4.systzdata
++++ php-5.3.1/ext/date/lib/timelib.m4
+@@ -78,3 +78,17 @@ stdlib.h
+
+ dnl Check for strtoll, atoll
+ AC_CHECK_FUNCS(strtoll atoll strftime)
++
++PHP_ARG_WITH(system-tzdata, for use of system timezone data,
++[ --with-system-tzdata[=DIR] to specify use of system timezone data],
++no, no)
++
++if test "$PHP_SYSTEM_TZDATA" != "no"; then
++ AC_DEFINE(HAVE_SYSTEM_TZDATA, 1, [Define if system timezone data is used])
++
++ if test "$PHP_SYSTEM_TZDATA" != "yes"; then
++ AC_DEFINE_UNQUOTED(HAVE_SYSTEM_TZDATA_PREFIX, "$PHP_SYSTEM_TZDATA",
++ [Define for location of system timezone data])
++ fi
++fi
++
--- /dev/null
+--- php-5.3.3/ext/sybase_ct/config.m4~ 2010-07-07 13:15:24.000000000 +0300
++++ php-5.3.3/ext/sybase_ct/config.m4 2010-07-24 19:21:13.897144810 +0300
+@@ -31,7 +31,7 @@
+ fi
+
+ PHP_ADD_LIBPATH($SYBASE_CT_LIBDIR, SYBASE_CT_SHARED_LIBADD)
+- if test -f $SYBASE_CT_INCDIR/tds.h || test -f $SYBASE_CT_INCDIR/tds_sysdep_public.h; then
++ if test -f $SYBASE_CT_INCDIR/tds.h || test -f $SYBASE_CT_INCDIR/tds_sysdep_public.h || test -f $SYBASE_CT_INCDIR/sybdb.h; then
+ PHP_ADD_LIBRARY(ct,, SYBASE_CT_SHARED_LIBADD)
+ SYBASE_CT_LIBS="-L$SYBASE_CT_LIBDIR -lct"
+ elif test -f $SYBASE_CT_INCDIR/libsybct64; then
--- /dev/null
+diff -burN php-5.0.4RC1.orig/TSRM/threads.m4 php-5.0.4RC1/TSRM/threads.m4
+--- php-5.0.4RC1.orig/TSRM/threads.m4 2005-03-15 18:02:27.630294512 +0100
++++ php-5.0.4RC1/TSRM/threads.m4 2005-03-15 18:07:05.301082136 +0100
+@@ -116,7 +116,6 @@
+ else
+ save_CFLAGS=$CFLAGS
+ save_LIBS=$LIBS
+- PTHREADS_ASSIGN_VARS
+ PTHREADS_CHECK_COMPILE
+ LIBS=$save_LIBS
+ CFLAGS=$save_CFLAGS
+@@ -134,9 +133,10 @@
+ break
+ fi
+ done
++ pthreads_working=
+ fi
+-fi
+ ])
++fi
+
+ AC_CACHE_CHECK(for pthreads_lib, ac_cv_pthreads_lib,[
+ ac_cv_pthreads_lib=
+@@ -163,6 +163,7 @@
+ dnl
+ dnl
+ AC_DEFUN([PTHREADS_ASSIGN_VARS],[
++if test "$pthreads_assign_done" != "yes" ; then
+ if test -n "$ac_cv_pthreads_lib"; then
+ LIBS="$LIBS -l$ac_cv_pthreads_lib"
+ fi
+@@ -170,4 +171,6 @@
+ if test -n "$ac_cv_pthreads_cflags"; then
+ CFLAGS="$CFLAGS $ac_cv_pthreads_cflags"
+ fi
++pthreads_assign_done="yes"
++fi
+ ])dnl
--- /dev/null
+diff -ur php5.3-200903291030/Zend/zend_strtod.c mod/Zend/zend_strtod.c
+--- php5.3-200903291030/Zend/zend_strtod.c 2009-03-18 12:36:20.000000000 +0100
++++ mod/Zend/zend_strtod.c 2009-03-29 18:34:10.000000000 +0200
+@@ -93,6 +93,7 @@
+
+ #include <zend_operators.h>
+ #include <zend_strtod.h>
++#include <stdint.h>
+
+ #ifdef ZTS
+ #include <TSRM.h>
--- /dev/null
+--- php-5.2.6/acinclude.m4~ 2008-10-15 13:44:25.000000000 +0300
++++ php-5.2.6/acinclude.m4 2008-10-15 13:55:05.359850285 +0300
+@@ -2037,8 +2037,10 @@
+ dnl Search for the sendmail binary
+ dnl
+ AC_DEFUN([PHP_PROG_SENDMAIL], [
+- PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib
+- AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:$PHP_ALT_PATH)
++ if test -z "$PROG_SENDMAIL"; then
++ PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib
++ AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:$PHP_ALT_PATH)
++ fi
+ PHP_SUBST(PROG_SENDMAIL)
+ ])
+
--- /dev/null
+make compressed .swf parsing possible,
+link core php with -lz for getimagesize()
+see also http://bugs.php.net/bug.php?id=29611
+
+--- php-4.4.1/ext/standard/image.c 2005-07-27 14:22:36.000000000 +0300
++++ /tmp/image.c 2006-01-06 19:14:00.000000000 +0200
+@@ -31,7 +31,7 @@
+ #endif
+ #include "php_image.h"
+
+-#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB)
++#if HAVE_ZLIB
+ #include "zlib.h"
+ #endif
+
+@@ -80,7 +80,7 @@
+ REGISTER_LONG_CONSTANT("IMAGETYPE_JP2", IMAGE_FILETYPE_JP2, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMAGETYPE_JPX", IMAGE_FILETYPE_JPX, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("IMAGETYPE_JB2", IMAGE_FILETYPE_JB2, CONST_CS | CONST_PERSISTENT);
+-#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB)
++#if HAVE_ZLIB
+ REGISTER_LONG_CONSTANT("IMAGETYPE_SWC", IMAGE_FILETYPE_SWC, CONST_CS | CONST_PERSISTENT);
+ #endif
+ REGISTER_LONG_CONSTANT("IMAGETYPE_IFF", IMAGE_FILETYPE_IFF, CONST_CS | CONST_PERSISTENT);
+@@ -184,7 +184,7 @@
+ }
+ /* }}} */
+
+-#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB)
++#if HAVE_ZLIB
+ /* {{{ php_handle_swc
+ */
+ static struct gfxinfo *php_handle_swc(php_stream * stream TSRMLS_DC)
+@@ -1267,7 +1290,7 @@
+ result = php_handle_swf(stream TSRMLS_CC);
+ break;
+ case IMAGE_FILETYPE_SWC:
+-#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB)
++#if HAVE_ZLIB
+ result = php_handle_swc(stream TSRMLS_CC);
+ #else
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "The image is a compressed SWF file, but you do not have a static version of the zlib extension enabled.");
--- /dev/null
+# NOTE: mysqlnd does not support ssl or compression (see FAQ at http://dev.mysql.com/downloads/connector/php-mysqlnd/)
+# TODO:
+# - ttyname_r() misdetected http://bugs.php.net/bug.php?id=48820
+# - wddx: restore session support (not compiled in due DL extension check)
+# - deal with modules removed from php and not moved to PECL, still not obsoleted anywhere
+# - removed from php 5.0 (currently in php4):
+# db [pecl-svn], hyperwave [pecl-svn], java [pecl-svn], mcal [pecl-svn], qtdom [pecl-svn]
+# - removed from php 5.1:
+# oracle [pecl-svn]
+# - removed from php 5.2:
+# filepro [pecl-svn], hwapi [pecl-svn]
+# - make additional headers and checking added by mail patch configurable
+# - modularize standard (output from pure php -m)?
+# - lib64 patch obsolete by $PHP_LIBDIR ?
+# - WARNING: Phar: sha256/sha512 signature support disabled if ext/hash is
+# built shared, also PHAR_HAVE_OPENSSL is false if openssl is built shared.
+# make it runtime dep and add Suggests (or php warning messages)
+# - some mods should be shared:
+#$ php -m
+# [PHP Modules]
+#+Core
+# date
+#+ereg
+# libxml
+# Reflection
+#
+# Conditional build:
+%bcond_with interbase_inst # use InterBase install., not Firebird (BR: proprietary libs)
+%bcond_with oci8 # with Oracle oci8 extension module (BR: proprietary libs)
+%bcond_with instantclient # build Oracle oci8 extension module against oracle-instantclient package
+%bcond_with system_gd # with system gd (we prefer internal since it enables few more features)
+%bcond_without curl # without CURL extension module
+%bcond_without filter # without filter extension module
+%bcond_without imap # without IMAP extension module
+%bcond_without interbase # without InterBase extension module
+%bcond_without kerberos5 # without Kerberos5 support
+%bcond_without litespeed # build litespeed module
+%bcond_without ldap # without LDAP extension module
+%bcond_without mhash # without mhash extension (supported by hash extension)
+%bcond_without mm # without mm support for session storage
+%bcond_without mssql # without MS SQL extension module
+# don't turn it on by default; see TODO item for mysqlnd in this spec
+%bcond_with mysqlnd # with mysqlnd support in mysql related extensions
+%bcond_without mysqli # without mysqli support (Requires mysql > 4.1)
+%bcond_without odbc # without ODBC extension module
+%bcond_without openssl # without OpenSSL support and OpenSSL extension (module)
+%bcond_without pcre # without PCRE extension module
+%bcond_without pdo_sqlite # without PDO SQLite extension module
+%bcond_without pgsql # without PostgreSQL extension module
+%bcond_without phar # without phar extension module
+%bcond_without pspell # without pspell extension module
+%bcond_without recode # without recode extension module
+%bcond_without snmp # without SNMP extension module
+%bcond_without sqlite2 # without SQLite extension module
+%bcond_without sqlite3 # without SQLite3 extension module
+%bcond_without sybase_ct # without Sybase-CT extension module
+%bcond_without tidy # without Tidy extension module
+%bcond_without wddx # without WDDX extension module
+%bcond_without xmlrpc # without XML-RPC extension module
+%bcond_without apache1 # disable building Apache 1.3.x SAPI
+%bcond_without apache2 # disable building Apache 2.x SAPI
+%bcond_with zts # Zend Thread Safety
+%bcond_without cgi # disable CGI/FCGI SAPI
+%bcond_without fpm # disable FPM
+%bcond_without suhosin # with suhosin patch
+%bcond_with tests # default off; test process very often hangs on builders, approx run time 45m; perform "make test"
+%bcond_with gcov # Enable Code coverage reporting
+%bcond_with type_hints # experimental support for strict typing/casting
+
+%define apxs1 /usr/sbin/apxs1
+%define apxs2 /usr/sbin/apxs
+%define litespeed_version 5.5
+
+# disable all sapis
+%if %{with gcov}
+%undefine with_apache1
+%undefine with_apache2
+%undefine with_cgi
+%undefine with_litespeed
+%endif
+
+# mm is not thread safe
+%if %{with zts}
+%undefine with_mm
+%endif
+
+%ifnarch %{ix86} %{x8664} sparc sparcv9 alpha
+# ppc disabled (broken on th-ppc)
+%undefine with_interbase
+%endif
+
+%ifnarch %{ix86} %{x8664}
+# unsupported, see sapi/cgi/fpm/fpm_atomic.h
+%undefine with_fpm
+%endif
+
+%if 0
+%if %{without apache1} && %{without apache2}
+ERROR: You need to select at least one Apache SAPI to build shared modules.
+%endif
+%endif
+
+# filter depends on pcre
+%if %{without pcre}
+%undefine with_filter
+%endif
+
+%define rel 11
+Summary: PHP: Hypertext Preprocessor
+Summary(fr.UTF-8): Le langage de script embarque-HTML PHP
+Summary(pl.UTF-8): Język skryptowy PHP
+Summary(pt_BR.UTF-8): A linguagem de script PHP
+Summary(ru.UTF-8): PHP Версии 5 - язык препроцессирования HTML-файлов, выполняемый на сервере
+Summary(uk.UTF-8): PHP Версії 5 - мова препроцесування HTML-файлів, виконувана на сервері
+Name: php
+Version: 5.3.6
+Release: %{rel}%{?with_type_hints:.th}%{?with_oci8:.oci}
+Epoch: 4
+License: PHP
+Group: Libraries
+Source0: http://www.php.net/distributions/%{name}-%{version}.tar.bz2
+# Source0-md5: 2286f5a82a6e8397955a0025c1c2ad98
+Source2: %{name}-mod_%{name}.conf
+Source3: %{name}-cgi-fcgi.ini
+Source4: %{name}-apache.ini
+Source5: %{name}-cli.ini
+# Taken from: http://browsers.garykeith.com/downloads.asp
+Source9: %{name}_browscap.ini
+Source10: %{name}-fpm.init
+Source11: %{name}-fpm.logrotate
+Source12: %{name}-branch.sh
+Source13: dep-tests.sh
+Source14: skip-tests.sh
+Source15: http://litespeedtech.com/packages/lsapi/%{name}-litespeed-%{litespeed_version}.tgz
+# Source15-md5: 9d58485d5fd6b5f5fefcec41b9ce283e
+Patch0: %{name}-shared.patch
+Patch1: %{name}-pldlogo.patch
+Patch2: %{name}-mail.patch
+Patch3: %{name}-link-libs.patch
+Patch4: %{name}-libpq_fs_h_path.patch
+Patch5: %{name}-filter-shared.patch
+Patch6: %{name}-build_modules.patch
+Patch7: %{name}-sapi-ini-file.patch
+Patch8: %{name}-config-file-scan-dir.patch
+Patch9: %{name}-sh.patch
+Patch10: %{name}-ini.patch
+%if %{with type_hints}
+Patch12: http://ilia.ws/patch/type_hint_53_v2.txt
+%endif
+Patch14: %{name}-no_pear_install.patch
+Patch15: %{name}-zlib.patch
+Patch17: %{name}-readline.patch
+Patch18: %{name}-nohttpd.patch
+Patch19: %{name}-gd_imagerotate_enable.patch
+Patch20: %{name}-uint32_t.patch
+Patch21: %{name}-dba-link.patch
+Patch22: %{name}-both-apxs.patch
+Patch23: %{name}-builddir.patch
+Patch24: %{name}-zlib-for-getimagesize.patch
+Patch25: %{name}-stupidapache_version.patch
+Patch26: %{name}-pear.patch
+Patch27: %{name}-config-dir.patch
+Patch29: %{name}-fcgi-graceful.patch
+Patch31: %{name}-fcgi-error_log-no-newlines.patch
+Patch32: %{name}-curl-limit-speed.patch
+Patch34: %{name}-libtool.patch
+Patch35: %{name}-tds.patch
+Patch36: %{name}-mysql-charsetphpini.patch
+Patch37: %{name}-mysqli-charsetphpini.patch
+Patch38: %{name}-pdo_mysql-charsetphpini.patch
+Patch39: %{name}-use-prog_sendmail.patch
+Patch41: %{name}-fpm-config.patch
+Patch42: %{name}-fpm-shared.patch
+Patch43: %{name}-silent-session-cleanup.patch
+Patch44: %{name}-include_path.patch
+Patch45: %{name}-imap-annotations.patch
+Patch46: %{name}-imap-myrights.patch
+Patch47: suhosin.patch
+Patch49: %{name}-m4-divert.patch
+Patch50: extension-shared-optional-dep.patch
+Patch51: spl-shared.patch
+Patch52: pcre-shared.patch
+Patch53: fix-test-run.patch
+Patch54: mysqlnd-shared.patch
+Patch55: bug-52078-fileinode.patch
+Patch57: bug-52448.patch
+Patch59: %{name}-systzdata.patch
+Patch60: %{name}-oracle-instantclient.patch
+Patch61: %{name}-krb5-ac.patch
+Patch62: mcrypt-libs.patch
+Patch63: %{name}-mysql-nowarning.patch
+Patch64: %{name}-buff_ovf.patch
+URL: http://www.php.net/
+%{?with_interbase:%{!?with_interbase_inst:BuildRequires: Firebird-devel >= 1.0.2.908-2}}
+%{?with_pspell:BuildRequires: aspell-devel >= 2:0.50.0}
+BuildRequires: autoconf >= 2.53
+BuildRequires: automake >= 1.4d
+BuildRequires: bison
+BuildRequires: bzip2-devel
+%{?with_curl:BuildRequires: curl-devel >= 7.12.0}
+BuildRequires: cyrus-sasl-devel
+BuildRequires: db-devel >= 4.0
+BuildRequires: elfutils-devel
+#BuildRequires: fcgi-devel
+#BuildRequires: flex
+%{?with_kerberos5:BuildRequires: heimdal-devel}
+BuildRequires: mysql-devel
+BuildRequires: pkgconfig
+BuildRequires: sed >= 4.0
+%if %{with mssql} || %{with sybase_ct}
+BuildRequires: freetds-devel >= 0.82
+%endif
+BuildRequires: freetype-devel >= 2.0
+%if %{with system_gd}
+BuildRequires: gd-devel >= 2.0.28-4
+BuildRequires: gd-devel(imagerotate) = 5.2.0
+%endif
+BuildRequires: gdbm-devel
+BuildRequires: gmp-devel
+%{?with_imap:BuildRequires: imap-devel >= 1:2007e-2}
+BuildRequires: libicu-devel
+BuildRequires: libjpeg-devel
+BuildRequires: libltdl-devel >= 1.4
+BuildRequires: libmcrypt-devel >= 2.4.4
+BuildRequires: libpng-devel >= 1.0.8
+#BuildRequires: libtiff-devel
+%if "%{pld_release}" != "ac"
+BuildRequires: libtool >= 2:2.2
+%else
+BuildRequires: libtool >= 1.4.3
+%endif
+#BuildRequires: libwrap-devel
+BuildRequires: libxml2-devel >= 1:2.7.6-4
+BuildRequires: libxslt-devel >= 1.1.0
+%{?with_mm:BuildRequires: mm-devel >= 1.3.0}
+%{?with_ldap:BuildRequires: openldap-devel >= 2.3.0}
+%if %{with openssl} || %{with ldap}
+BuildRequires: openssl-devel >= 0.9.7d
+%endif
+%{?with_gcov:BuildRequires: lcov}
+%{?with_snmp:%{?with_tests:BuildRequires: mibs-net-snmp}}
+%{?with_snmp:BuildRequires: net-snmp-devel >= 5.0.7}
+%{?with_instantclient:BuildRequires: oracle-instantclient-devel}
+BuildRequires: pam-devel
+%{?with_pcre:BuildRequires: pcre-devel >= 8.10}
+BuildRequires: pkgconfig
+%{?with_pgsql:BuildRequires: postgresql-backend-devel >= 7.2}
+%{?with_pgsql:BuildRequires: postgresql-devel}
+BuildRequires: readline-devel
+%{?with_recode:BuildRequires: recode-devel >= 3.5d-3}
+BuildRequires: rpm >= 4.4.9-56
+BuildRequires: rpm-build >= 4.4.0
+BuildRequires: rpmbuild(macros) >= 1.566
+%{?with_sqlite2:BuildRequires: sqlite-devel}
+%if %{with sqlite3} || %{with pdo_sqlite}
+BuildRequires: sqlite3-devel >= 3.3.9
+%endif
+BuildRequires: t1lib-devel
+%{?with_tidy:BuildRequires: tidy-devel}
+%{?with_odbc:BuildRequires: unixODBC-devel}
+%{?with_xmlrpc:BuildRequires: xmlrpc-epi-devel >= 0.54.1}
+BuildRequires: zlib-devel >= 1.0.9
+%if %{with apache1}
+BuildRequires: apache1-devel
+%endif
+%if %{with apache2}
+BuildRequires: apache-devel >= 2.0.52-2
+BuildRequires: apr-devel >= 1:1.0.0
+BuildRequires: apr-util-devel >= 1:1.0.0
+%endif
+%if %{with fpm}
+#BuildRequires: judy-devel
+BuildRequires: libevent-devel >= 1.4.7-3
+%endif
+BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%define php_sysconfdir /etc/php
+%define php_extensiondir %{_libdir}/php
+%define _sysconfdir %{php_sysconfdir}
+
+# must be in sync with source. extra check ensuring that it is so is done in %%build
+%define php_api_version 20090626
+%define zend_module_api 20090626
+%define zend_extension_api 220090626
+
+%define zend_zts %{!?with_zts:0}%{?with_zts:1}
+%define php_debug %{!?debug:0}%{?debug:1}
+
+%if %{with gcov}
+%undefine with_ccache
+%endif
+
+%if %{with oci8}
+# ORACLE_HOME is required for oci8 ext to build
+%define _preserve_env %_preserve_env_base ORACLE_HOME
+%endif
+
+%description
+PHP is an HTML-embedded scripting language. PHP attempts to make it
+easy for developers to write dynamically generated web pages. PHP also
+offers built-in database integration for several commercial and
+non-commercial database management systems, so writing a
+database-enabled web page with PHP is fairly simple. The most common
+use of PHP coding is probably as a replacement for CGI scripts. The
+mod_php module enables the Apache web server to understand and process
+the embedded PHP language in web pages. This package contains PHP
+version %{version}.
+
+%description -l fr.UTF-8
+PHP est un langage de script embarque dans le HTM. PHP essaye de
+rendre simple aux developpeurs d'ecrire des pages web generees
+dynamiquement. PHP incorpore egalement une integration avec plusieurs
+systemes de gestion de bases de donnees commerciaux et
+non-connerciaux, qui rent facile la creation de pages web liees avec
+des bases de donnees. L'utilisation la plus commune de PHP est
+probablement en remplacement de scripts CGI. Le module mod_php permet
+au serveur web Apache de comprendre et de traiter le langage PHP
+integre dans des pages web. Ce package contient PHP version
+%{version}.
+
+%description -l pl.UTF-8
+PHP jest językiem skryptowym, którego polecenia umieszcza się w
+plikach HTML. Jest próbą ułatwienia programistom pisania dynamicznie
+generowanych stron WWW. Oferuje także wbudowaną integrację z bazami
+danych dla kilku komercyjnych i niekomercyjnych systemów baz danych,
+co czyni tworzenie stron korzystających z baz danych w miarę łatwym.
+Najczęściej PHP jest używany prawdopodobnie jako zamiennik skryptów
+CGI. Moduł mod_php pozwala serwerowi WWW Apache rozumieć i przetwarzać
+język PHP osadzony w stronach. Ten pakiet zawiera PHP w wersji
+%{version}.
+
+%description -l pt_BR.UTF-8
+PHP: Preprocessador de Hipertexto versão 4 é uma linguagem script
+embutida em HTML. Muito de sua sintaxe é emprestada de C, Java e Perl,
+com algumas características únicas, específicas ao PHP. O objetivo da
+linguagem é permitir que desenvolvedores web escrevam páginas
+dinamicamente geradas de forma rápida.
+
+%description -l ru.UTF-8
+PHP - это язык написания скриптов, встраиваемых в HTML-код. PHP
+предлагает интерграцию с множеством СУБД, поэтому написание скриптов
+для работы с базами данных относительно просто. Наиболее популярное
+использование PHP - замена для CGI скриптов.
+
+%description -l uk.UTF-8
+PHP - це мова написання скриптів, що вбудовуються в HTML-код. PHP
+пропонує інтеграцію з багатьма СУБД, тому написання скриптів для
+роботи з базами даних є доволі простим. Найбільш популярне
+використання PHP - заміна для CGI скриптів.
+
+%package -n apache1-mod_php
+Summary: PHP DSO module for Apache 1.3.x
+Summary(pl.UTF-8): Moduł DSO (Dynamic Shared Object) PHP dla Apache 1.3.x
+Group: Development/Languages/PHP
+Requires(triggerpostun): sed >= 4.0
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: apache1(EAPI) >= 1.3.33-2
+Requires: apache1-mod_mime
+Provides: webserver(php) = %{version}
+Obsoletes: apache-mod_php < 1:4.1.1
+Obsoletes: phpfi
+
+%description -n apache1-mod_php
+PHP as DSO module for Apache 1.3.x.
+
+%description -n apache1-mod_php -l pl.UTF-8
+PHP jako moduł DSO (Dynamic Shared Object) dla Apache 1.3.x.
+
+%package -n apache-mod_php
+Summary: PHP DSO module for Apache 2.x
+Summary(pl.UTF-8): Moduł DSO (Dynamic Shared Object) PHP dla Apache 2.x
+Group: Development/Languages/PHP
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: apache(modules-api) = %{apache_modules_api}
+Requires: apache-mod_mime
+Provides: webserver(php) = %{version}
+Obsoletes: phpfi
+
+%description -n apache-mod_php
+PHP as DSO module for Apache 2.x.
+
+%description -n apache-mod_php -l pl.UTF-8
+PHP jako moduł DSO (Dynamic Shared Object) dla Apache 2.x.
+
+%package litespeed
+Summary: PHP for litespeed HTTP server
+Summary(pl.UTF-8): PHP dla serwera HTTP litespeed
+Group: Development/Languages/PHP
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: webserver(php) = %{version}
+
+%description litespeed
+PHP for litespeed HTTP server.
+
+%description litespeed -l pl.UTF-8
+PHP dla serwera HTTP litespeed.
+
+%package cgi
+Summary: PHP as CGI/FastCGI program
+Summary(pl.UTF-8): PHP jako program CGI/FastCGI
+Group: Development/Languages/PHP
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: %{name}-fcgi = %{epoch}:%{version}-%{release}
+Provides: php(cgi)
+Provides: php(fcgi)
+Provides: webserver(php)
+Obsoletes: php-fcgi < 4:5.3.0
+
+%description cgi
+PHP as CGI or FastCGI program.
+
+%description cgi -l pl.UTF-8
+PHP jako program CGI lub FastCGI.
+
+%package cli
+Summary: PHP as CLI interpreter
+Summary(pl.UTF-8): PHP jako interpreter działający z linii poleceń
+Group: Development/Languages/PHP
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+
+%description cli
+PHP as CLI interpreter.
+
+%description cli -l pl.UTF-8
+PHP jako interpreter działający z linii poleceń.
+
+%package program
+Summary: /usr/bin/php symlink
+Summary(pl.UTF-8): Dowiązanie symboliczne /usr/bin/php
+Group: Development/Languages/PHP
+Requires: %{name}-cli = %{epoch}:%{version}-%{release}
+Obsoletes: /usr/bin/php
+
+%description program
+Package providing /usr/bin/php symlink to PHP CLI.
+
+%description program -l pl.UTF-8
+Pakiet dostarczający dowiązanie symboliczne /usr/bin/php do PHP CLI.
+
+%package fpm
+Summary: PHP FastCGI Process Manager
+Summary(pl.UTF-8): PHP FastCGI Process Manager - zarządca procesów FastCGI
+Group: Development/Languages/PHP
+URL: http://www.php-fpm.org/
+Requires(post,preun): /sbin/chkconfig
+Requires(postun): /usr/sbin/userdel
+Requires(pre): /bin/id
+Requires(pre): /usr/sbin/useradd
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: libevent >= 1.4.7-3
+Requires: rc-scripts
+Provides: user(http)
+Provides: webserver(php) = %{version}
+
+%description fpm
+PHP FastCGI Process Manager.
+
+%description fpm -l pl.UTF-8
+PHP FastCGI Process Manager - zarządca procesów FastCGI.
+
+%package common
+Summary: Common files needed by both Apache modules and CGI/CLI SAPIs
+Summary(pl.UTF-8): Wspólne pliki dla modułu Apache'a i programu CGI
+Summary(ru.UTF-8): Разделяемые библиотеки для PHP
+Summary(uk.UTF-8): Бібліотеки спільного використання для PHP
+Group: Libraries
+Requires(post): sed >= 4.0
+# because of dlclose() bugs in glibc <= 2.3.4 causing SEGVs on exit
+Requires: glibc >= 6:2.3.5
+Requires: php-dirs
+Requires: rpm-whiteout >= 1.28
+Requires: tzdata
+Provides: php(date)
+Provides: php(ereg)
+Provides: php(hash)
+Provides: php(libxml)
+Provides: php(modules_api) = %{php_api_version}
+Provides: php(reflection)
+Provides: php(standard)
+Provides: php(zend_extension_api) = %{zend_extension_api}
+Provides: php(zend_module_api) = %{zend_module_api}
+Provides: php-date
+Provides: php-ereg
+Provides: php-reflection
+Provides: php-standard
+Provides: php5(debug) = %{php_debug}
+Provides: php5(thread-safety) = %{zend_zts}
+%{!?with_mysqlnd:Obsoletes: php-mysqlnd}
+%{?with_pcre:%requires_ge_to pcre pcre-devel}
+Obsoletes: php-pecl-domxml
+Conflicts: php4-common < 3:4.4.4-8
+Conflicts: rpm < 4.4.2-0.2
+
+%description common
+Common files needed by both Apache modules and CGI/CLI SAPIs.
+
+%description common -l pl.UTF-8
+Wspólne pliki dla modułu Apache'a i programu CGI.
+
+%description common -l ru.UTF-8
+Этот пакет содержит общие файлы для разных вариантов реализации PHP
+(самодостаточной и в качестве модуля Apache).
+
+%description common -l uk.UTF-8
+Цей пакет містить спільні файли для різних варіантів реалізації PHP
+(самодостатньої та в якості модуля Apache).
+
+%package devel
+Summary: Files for PHP modules development
+Summary(pl.UTF-8): Pliki do kompilacji modułów PHP
+Summary(pt_BR.UTF-8): Arquivos de desenvolvimento para PHP
+Summary(ru.UTF-8): Пакет разработки для построения расширений PHP
+Summary(uk.UTF-8): Пакет розробки для побудови розширень PHP
+Group: Development/Languages/PHP
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: autoconf
+Requires: automake
+%if "%{pld_release}" != "ac"
+Requires: libtool >= 2:2.2
+%else
+Requires: libtool
+%endif
+%{?with_pcre:Requires: pcre-devel >= 8.10}
+Requires: shtool
+Obsoletes: php-pear-devel
+Obsoletes: php4-devel
+
+%description devel
+The php-devel package lets you compile dynamic extensions to PHP.
+Included here is the source for the PHP extensions. Instead of
+recompiling the whole PHP binary to add support for, say, oracle,
+install this package and use the new self-contained extensions
+support. For more information, read the file
+README.SELF-CONTAINED-EXTENSIONS.
+
+%description devel -l pl.UTF-8
+Ten pakiet zawiera pliki potrzebne do kompilacji modułów PHP. Zamiast
+rekompilować całe PHP aby dodać obsługę np. oracle, można przy użyciu
+tego pakietu skompilować samodzielne rozszerzenie. Więcej informacji o
+samodzielnych rozszerzeniach można znaleźć w pliku
+README.SELF-CONTAINED-EXTENSIONS.
+
+%description devel -l pt_BR.UTF-8
+Este pacote contém arquivos usados no desenvolvimento de programas ou
+módulos PHP.
+
+%description devel -l ru.UTF-8
+Пакет php-devel дает возможность компилировать динамические расширения
+PHP. Пакет включает исходный код этих расширений. Вместо повторной
+компиляции бинарного файла PHP для добавления, например, поддержки
+oracle, установите этот пакет для компилирования отдельных расширений.
+Подробности - в файле README.SELF-CONTAINED-EXTENSIONS.
+
+%description devel -l uk.UTF-8
+Пакет php-devel дає можливість компілювати динамічні розширення PHP.
+До пакету включено вихідний код для розширень. Замість повторної
+компіляції бінарного файлу PHP для додання, наприклад, підтримки
+oracle, встановіть цей пакет для компіляції окремих розширень.
+Детальніша інформація - в файлі README.SELF-CONTAINED-EXTENSIONS.
+
+%package bcmath
+Summary: bcmath extension module for PHP
+Summary(pl.UTF-8): Moduł bcmath dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.bc.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(bcmath)
+
+%description bcmath
+This is a dynamic shared object (DSO) for PHP that will add bc style
+precision math functions support.
+
+%description bcmath -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z dokładnych funkcji
+matematycznych takich jak w programie bc.
+
+%package bz2
+Summary: Bzip2 extension module for PHP
+Summary(pl.UTF-8): Moduł bzip2 dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.bzip2.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(bz2)
+Provides: php(bzip2)
+Provides: php-bzip2 = %{epoch}:%{version}-%{release}
+Obsoletes: php-bzip2 < 4:5.2.14-3
+
+%description bz2
+This is a dynamic shared object (DSO) for PHP that will add bzip2
+compression support to PHP.
+
+%description bz2 -l pl.UTF-8
+Moduł PHP umożliwiający używanie kompresji bzip2.
+
+%package calendar
+Summary: Calendar extension module for PHP
+Summary(pl.UTF-8): Moduł funkcji kalendarza dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.calendar.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(calendar)
+
+%description calendar
+This is a dynamic shared object (DSO) for PHP that will add calendar
+support.
+
+%description calendar -l pl.UTF-8
+Moduł PHP dodający wsparcie dla kalendarza.
+
+%package ctype
+Summary: ctype extension module for PHP
+Summary(pl.UTF-8): Moduł ctype dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.ctype.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(ctype)
+
+%description ctype
+This is a dynamic shared object (DSO) for PHP that will add ctype
+support.
+
+%description ctype -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z funkcji ctype.
+
+%package curl
+Summary: curl extension module for PHP
+Summary(pl.UTF-8): Moduł curl dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.curl.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(curl)
+
+%description curl
+This is a dynamic shared object (DSO) for PHP that will add curl
+support.
+
+%description curl -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z biblioteki curl.
+
+%package dba
+Summary: DBA extension module for PHP
+Summary(pl.UTF-8): Moduł DBA dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.dba.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(dba)
+
+%description dba
+This is a dynamic shared object (DSO) for PHP that will add flat-file
+databases (DBA) support.
+
+%description dba -l pl.UTF-8
+Moduł dla PHP dodający obsługę dla baz danych opartych na plikach
+(DBA).
+
+%package dom
+Summary: DOM extension module for PHP
+Summary(pl.UTF-8): Moduł DOM dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.dom.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(dom)
+# it has some compatibility functions
+Provides: php(domxml)
+Provides: php-domxml = %{epoch}:%{version}-%{release}
+Obsoletes: php-domxml <= 3:4.3.8-1
+
+%description dom
+This is a dynamic shared object (DSO) for PHP that will add new DOM
+support.
+
+%description dom -l pl.UTF-8
+Moduł PHP dodający nową obsługę DOM.
+
+%package exif
+Summary: exif extension module for PHP
+Summary(pl.UTF-8): Moduł exif dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.exif.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(exif)
+
+%description exif
+This is a dynamic shared object (DSO) for PHP that will add EXIF tags
+support in image files.
+
+%description exif -l pl.UTF-8
+Moduł PHP dodający obsługę znaczników EXIF w plikach obrazków.
+
+%package fileinfo
+Summary: libmagic bindings
+Summary(pl.UTF-8): Wiązania do libmagic
+Group: Libraries
+URL: http://www.php.net/manual/en/book.fileinfo.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-pcre = %{epoch}:%{version}-%{release}
+Provides: php(fileinfo)
+Obsoletes: php-mime_magic
+Obsoletes: php-pecl-fileinfo
+
+%description fileinfo
+This extension allows retrieval of information regarding vast majority
+of file. This information may include dimensions, quality, length
+etc...
+
+Additionally it can also be used to retrieve the MIME type for a
+particular file and for text files proper language encoding.
+
+%description fileinfo -l pl.UTF-8
+To rozszerzenie pozwala na uzyskanie informacji dotyczących większości
+plików. Informacje mogą zawierać wymiary, jakość, długość itp.
+
+Ponadto rozszerzenie można wykorzystać do odczytania typu MIME danego
+pliku oraz kodowania plików tekstowych.
+
+%package filter
+Summary: Extension for safely dealing with input parameters
+Summary(pl.UTF-8): Rozszerzenie do bezpiecznej obsługi danych wejściowych
+Group: Libraries
+URL: http://www.php.net/manual/en/book.filter.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-pcre = %{epoch}:%{version}-%{release}
+Provides: php(filter)
+Obsoletes: php-pecl-filter
+
+%description filter
+We all know that you should always check input variables, but PHP does
+not offer really good functionality for doing this in a safe way. The
+Input Filter extension is meant to address this issue by implementing
+a set of filters and mechanisms that users can use to safely access
+their input data.
+
+%description filter -l pl.UTF-8
+Wiadomo, że trzeba zawsze sprawdzać zmienne wejściowe, ale PHP nie
+oferuje naprawdę dobrej funkcjonalności do robienia tego w sposób
+bezpieczny. Rozszerzenie Input Filter ma rozwiązać ten problem poprzez
+zaimplementowanie zestawu filtrów i mechanizmów, których użytkownicy
+mogą bezpiecznie używać do dostępu do danych.
+
+%package ftp
+Summary: FTP extension module for PHP
+Summary(pl.UTF-8): Moduł FTP dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.ftp.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(ftp)
+
+%description ftp
+This is a dynamic shared object (DSO) for PHP that will add FTP
+support.
+
+%description ftp -l pl.UTF-8
+Moduł PHP dodający obsługę protokołu FTP.
+
+%package gd
+Summary: GD extension module for PHP
+Summary(pl.UTF-8): Moduł GD dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.image.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+%if %{with system_gd}
+Requires: gd >= 2.0.28-4
+Requires: gd(gif)
+Requires: gd(imagerotate) = 5.2.0
+%endif
+Provides: php(gd)
+
+%description gd
+This is a dynamic shared object (DSO) for PHP that will add GD
+support, allowing you to create and manipulate images with PHP.
+
+%description gd -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z biblioteki GD, pozwalającej na
+tworzenie i obróbkę obrazków.
+
+%package gettext
+Summary: gettext extension module for PHP
+Summary(pl.UTF-8): Moduł gettext dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.gettext.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(gettext)
+
+%description gettext
+This is a dynamic shared object (DSO) for PHP that will add gettext
+support.
+
+%description gettext -l pl.UTF-8
+Moduł PHP dodający obsługę lokalizacji przez gettext.
+
+%package gmp
+Summary: gmp extension module for PHP
+Summary(pl.UTF-8): Moduł gmp dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.gmp.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(gmp)
+
+%description gmp
+This is a dynamic shared object (DSO) for PHP that will add arbitrary
+length number support with GNU MP library.
+
+%description gmp -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z biblioteki gmp do obliczeń na
+liczbach o dowolnej długości.
+
+%package hash
+Summary: HASH Message Digest Framework
+Summary(pl.UTF-8): Szkielet do obliczania skrótów wiadomości
+Group: Libraries
+URL: http://www.php.net/manual/en/book.gmp.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(hash)
+%if %{with mhash}
+Provides: php(mhash)
+Provides: php-mhash = %{epoch}:%{version}-%{release}
+Obsoletes: php-mhash < 4:5.3.0
+%endif
+Obsoletes: php-pecl-hash
+
+%description hash
+Native implementations of common message digest algorithms using a
+generic factory method.
+
+%description hash -l pl.UTF-8
+Natywne implementacje popularnych algorytmów obliczania skrótów
+wiadomości przy użyciu wspólnego interfejsu.
+
+%package iconv
+Summary: iconv extension module for PHP
+Summary(pl.UTF-8): Moduł iconv dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.iconv.php
+Requires: %{_libdir}/gconv
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: iconv
+Provides: php(iconv)
+
+%description iconv
+This is a dynamic shared object (DSO) for PHP that will add iconv
+support.
+
+%description iconv -l pl.UTF-8
+Moduł PHP dodający obsługę iconv.
+
+%package imap
+Summary: IMAP extension module for PHP
+Summary(pl.UTF-8): Moduł IMAP dla PHP
+Summary(pt_BR.UTF-8): Um módulo para aplicações PHP que usam IMAP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.imap.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-pcre = %{epoch}:%{version}-%{release}
+Requires: imap-lib >= 1:2007e-2
+Provides: php(imap)
+
+%description imap
+This is a dynamic shared object (DSO) for PHP that will add IMAP
+support.
+
+%description imap -l pl.UTF-8
+Moduł PHP dodający obsługę skrzynek IMAP.
+
+%description imap -l pt_BR.UTF-8
+Um módulo para aplicações PHP que usam IMAP.
+
+%package interbase
+Summary: InterBase/Firebird database module for PHP
+Summary(pl.UTF-8): Moduł bazy danych InterBase/Firebird dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.ibase.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(interbase)
+%{?with_interbase_inst:Autoreq: false}
+
+%description interbase
+This is a dynamic shared object (DSO) for PHP that will add InterBase
+and Firebird database support.
+
+%description interbase -l pl.UTF-8
+Moduł PHP umożliwiający dostęp do baz danych InterBase i Firebird.
+
+%package intl
+Summary: Internationalization extension (ICU wrapper)
+Summary(pl.UTF-8): Rozszerzenie do internacjonalizacji (interfejs do ICU)
+Group: Libraries
+URL: http://www.php.net/intl
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(intl)
+
+%description intl
+Internationalization extension (further is referred as Intl) is a
+wrapper for ICU library, enabling PHP programmers to perform
+UCA-conformant collation and date/time/number/currency formatting in
+their scripts.
+
+%description intl -l pl.UTF-8
+Rozszerzenie do internacjonalizacji (dalej nazywane Intl) jest
+interfejsem do biblioteki ICU, pozwalającym programistom PHP na
+wykonywanie w skryptach porównań zgodnych z UCA oraz formatowania
+daty/czasu/walut.
+
+%package json
+Summary: PHP C extension for JSON serialization
+Summary(pl.UTF-8): Rozszerzenie C PHP dla serializacji JSON
+Group: Libraries
+URL: http://www.php.net/manual/en/book.json.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(json)
+Obsoletes: php-pecl-json
+
+%description json
+php-json is an extremely fast PHP C extension for JSON (JavaScript
+Object Notation) serialisation.
+
+%description json -l pl.UTF-8
+php-json to bardzo szybkie rozszerzenie C PHP dla serializacji JSON
+(JavaScript Object Notation).
+
+%package ldap
+Summary: LDAP extension module for PHP
+Summary(pl.UTF-8): Moduł LDAP dla PHP
+Summary(pt_BR.UTF-8): Um módulo para aplicações PHP que usam LDAP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.ldap.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(ldap)
+
+%description ldap
+This is a dynamic shared object (DSO) for PHP that will add LDAP
+support.
+
+%description ldap -l pl.UTF-8
+Moduł PHP dodający obsługę LDAP.
+
+%description ldap -l pt_BR.UTF-8
+Um módulo para aplicações PHP que usam LDAP.
+
+%package mbstring
+Summary: mbstring extension module for PHP
+Summary(pl.UTF-8): Moduł mbstring dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.mbstring.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(mbstring)
+
+%description mbstring
+This is a dynamic shared object (DSO) for PHP that will add multibyte
+string support.
+
+%description mbstring -l pl.UTF-8
+Moduł PHP dodający obsługę ciągów znaków wielobajtowych.
+
+%package mcrypt
+Summary: mcrypt extension module for PHP
+Summary(pl.UTF-8): Moduł mcrypt dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.mcrypt.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(mcrypt)
+
+%description mcrypt
+This is a dynamic shared object (DSO) for PHP that will add mcrypt
+support.
+
+%description mcrypt -l pl.UTF-8
+Moduł PHP dodający możliwość szyfrowania poprzez bibliotekę mcrypt.
+
+%package mssql
+Summary: MS SQL extension module for PHP
+Summary(pl.UTF-8): Moduł MS SQL dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.mssql.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(mssql)
+
+%description mssql
+This is a dynamic shared object (DSO) for PHP that will add MS SQL
+databases support through FreeTDS library.
+
+%description mssql -l pl.UTF-8
+Moduł PHP dodający obsługę baz danych MS SQL poprzez bibliotekę
+FreeTDS.
+
+%package mysql
+Summary: MySQL database module for PHP
+Summary(pl.UTF-8): Moduł bazy danych MySQL dla PHP
+Summary(pt_BR.UTF-8): Um módulo para aplicações PHP que usam bancos de dados MySQL
+Group: Libraries
+URL: http://www.php.net/manual/en/book.mysql.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+%{?with_mysqlnd:Requires: %{name}-mysqlnd = %{epoch}:%{version}-%{release}}
+Provides: php(mysql)
+
+%description mysql
+This is a dynamic shared object (DSO) for PHP that will add MySQL
+database support.
+
+%description mysql -l pl.UTF-8
+Moduł PHP umożliwiający dostęp do bazy danych MySQL.
+
+%description mysql -l pt_BR.UTF-8
+Um módulo para aplicações PHP que usam bancos de dados MySQL.
+
+%package mysqli
+Summary: MySQLi module for PHP
+Summary(pl.UTF-8): Moduł MySQLi dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.mysqli.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+%{?with_mysqlnd:Requires: %{name}-mysqlnd = %{epoch}:%{version}-%{release}}
+Requires: %{name}-spl = %{epoch}:%{version}-%{release}
+Provides: php(mysqli)
+
+%description mysqli
+This is a dynamic shared object (DSO) for PHP that will add MySQLi
+(Improved MySQL) support. The difference between it and mysql module
+is that it provides access to functionality of MySQL 4.1 and above.
+
+%description mysqli -l pl.UTF-8
+Moduł PHP umożliwiający udoskonalony dostęp do bazy danych MySQL.
+Różnicą między nim a modułem mysql jest dostęp do funkcjonalności
+MySQL w wersji 4.1 i nowszych.
+
+%package mysqlnd
+Summary: MySQL Native Client Driver for PHP
+Summary(pl.UTF-8): Sterownik natywnego klienta MySQL dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.mysqlnd.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(mysqlnd)
+
+%description mysqlnd
+MySQL Native Driver is a replacement for the MySQL Client Library
+(libmysql).
+
+Because MySQL Native Driver is written as a PHP extension, it is
+tightly coupled to the workings of PHP. This leads to gains in
+efficiency, especially when it comes to memory usage, as the driver
+uses the PHP memory management system. It also supports the PHP memory
+limit. Using MySQL Native Driver leads to comparable or better
+performance than using MySQL Client Library, it always ensures the
+most efficient use of memory. One example of the memory efficiency is
+the fact that when using the MySQL Client Library, each row is stored
+in memory twice, whereas with the MySQL Native Driver each row is only
+stored once in memory.
+
+%description mysqlnd -l pl.UTF-8
+MySQL Native Driver (natywny sterownik MySQL) to zamiennik biblioteki
+klienckiej MySQL (libmysql).
+
+Ponieważ sterownik natywny jest napisany jako rozszerzenie PHP, jest
+ściśle powiązany z pracą PHP. Daje to większą wydajność, zwłaszcza
+jeśli chodzi o wykorzystanie pamięci, jako że sterownik wykorzystuje
+system zarządzania pamięcią PHP; obsługuje także ograniczenie pamięci
+z PHP. Niniejszy sterownik ma wydajność porównywalną lub lepszą niż
+biblioteka kliencka MySQL, a pamięć zawsze wykorzystuje efektywniej.
+Przykładem tego może być fakt, że w przypadku biblioteki klienckiej
+każdy wiersz jest przechowywany w pamięci dwukrotnie, natomiast przy
+tym sterowniku - tylko raz.
+
+%package oci8
+Summary: Oracle 8+ database module for PHP
+Summary(pl.UTF-8): Moduł bazy danych Oracle 8+ dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.oci8.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(oci8)
+AutoReq: false
+
+%description oci8
+This is a dynamic shared object (DSO) for PHP that will add Oracle 7,
+8, 9 and 10 database support through Oracle8 Call-Interface (OCI8).
+
+%description oci8 -l pl.UTF-8
+Moduł PHP umożliwiający dostęp do bazy danych Oracle 7, 8, 9 i 10
+poprzez interfejs Oracle8 Call-Interface (OCI8).
+
+%package odbc
+Summary: ODBC extension module for PHP
+Summary(pl.UTF-8): Moduł ODBC dla PHP
+Summary(pt_BR.UTF-8): Um módulo para aplicações PHP que usam bases de dados ODBC
+Group: Libraries
+URL: http://www.php.net/manual/en/book.uodbc.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: unixODBC >= 2.1.1-3
+Provides: php(odbc)
+
+%description odbc
+This is a dynamic shared object (DSO) for PHP that will add ODBC
+support.
+
+%description odbc -l pl.UTF-8
+Moduł PHP ze wsparciem dla ODBC.
+
+%description odbc -l pt_BR.UTF-8
+Um módulo para aplicações PHP que usam ODBC.
+
+%package openssl
+Summary: OpenSSL extension module for PHP
+Summary(pl.UTF-8): Moduł OpenSSL dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.openssl.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(openssl)
+
+%description openssl
+This is a dynamic shared object (DSO) for PHP that will add OpenSSL
+support.
+
+%description openssl -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z biblioteki OpenSSL.
+
+%package pcntl
+Summary: Process Control extension module for PHP
+Summary(pl.UTF-8): Moduł Process Control dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.pcntl.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(pcntl)
+
+%description pcntl
+This is a dynamic shared object (DSO) for PHP that will add process
+spawning and control support. It supports functions like fork(),
+waitpid(), signal() etc.
+
+%description pcntl -l pl.UTF-8
+Moduł PHP umożliwiający tworzenie nowych procesów i kontrolę nad nimi.
+Obsługuje funkcje takie jak fork(), waitpid(), signal() i podobne.
+
+%package pcre
+Summary: PCRE extension module for PHP
+Summary(pl.UTF-8): Moduł PCRE dla PHP
+Group: Libraries
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(pcre)
+
+%description pcre
+This is a dynamic shared object (DSO) for PHP that will add Perl
+Compatible Regular Expression support.
+
+%description pcre -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z perlowych wyrażeń regularnych
+(Perl Compatible Regular Expressions)
+
+%package pdo
+Summary: PHP Data Objects (PDO)
+Summary(pl.UTF-8): Obsługa PHP Data Objects (PDO)
+Group: Libraries
+URL: http://www.php.net/manual/en/book.pdo.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-spl = %{epoch}:%{version}-%{release}
+Provides: php(pdo)
+Obsoletes: php-pecl-PDO
+
+%description pdo
+This is a dynamic shared object (DSO) for PHP that will add PDO
+support.
+
+%description pdo -l pl.UTF-8
+Moduł PHP dodający obsługę PDO (PHP Data Objects).
+
+%package pdo-dblib
+Summary: PHP Data Objects (PDO) FreeTDS support
+Summary(pl.UTF-8): Moduł PHP Data Objects (PDO) z obsługą FreeTDS
+Group: Libraries
+URL: http://www.php.net/manual/en/ref.pdo-dblib.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-pdo = %{epoch}:%{version}-%{release}
+Provides: php(dblib)
+
+%description pdo-dblib
+This is a dynamic shared object (DSO) for PHP that will add PDO
+FreeTDS support.
+
+%description pdo-dblib -l pl.UTF-8
+Moduł dla PHP dodający obsługę baz danych FreeTDS za pośrednictwem
+interfejsu PDO.
+
+%package pdo-firebird
+Summary: PHP Data Objects (PDO) Firebird support
+Summary(pl.UTF-8): Moduł PHP Data Objects (PDO) z obsługą Firebirda
+Group: Libraries
+URL: http://www.php.net/manual/en/ref.pdo-firebird.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-pdo = %{epoch}:%{version}-%{release}
+Provides: php(pdo-firebird)
+Obsoletes: php-pecl-PDO_FIREBIRD
+
+%description pdo-firebird
+This is a dynamic shared object (DSO) for PHP that will add PDO
+Firebird support.
+
+%description pdo-firebird -l pl.UTF-8
+Moduł dla PHP dodający obsługę baz danych Firebird za pośrednictwem
+interfejsu PDO.
+
+%package pdo-mysql
+Summary: PHP Data Objects (PDO) MySQL support
+Summary(pl.UTF-8): Moduł PHP Data Objects (PDO) z obsługą MySQL-a
+Group: Libraries
+URL: http://www.php.net/manual/en/ref.pdo-mysql.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+%{?with_mysqlnd:Requires: %{name}-mysqlnd = %{epoch}:%{version}-%{release}}
+Requires: %{name}-pdo = %{epoch}:%{version}-%{release}
+Provides: php(pdo-mysql)
+Obsoletes: php-pecl-PDO_MYSQL
+
+%description pdo-mysql
+This is a dynamic shared object (DSO) for PHP that will add PDO MySQL
+support.
+
+%description pdo-mysql -l pl.UTF-8
+Moduł dla PHP dodający obsługę baz danych MySQL za pośrednictwem
+interfejsu PDO.
+
+%package pdo-oci
+Summary: PHP Data Objects (PDO) Oracle support
+Summary(pl.UTF-8): Moduł PHP Data Objects (PDO) z obsługą Oracle'a
+Group: Libraries
+URL: http://www.php.net/manual/en/ref.pdo-oci.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-pdo = %{epoch}:%{version}-%{release}
+Provides: php(pdo-oci)
+Obsoletes: php-pecl-PDO_OCI
+
+%description pdo-oci
+This is a dynamic shared object (DSO) for PHP that will add PDO Oracle
+support.
+
+%description pdo-oci -l pl.UTF-8
+Moduł dla PHP dodający obsługę baz danych Oracle za pośrednictwem
+interfejsu PDO.
+
+%package pdo-odbc
+Summary: PHP Data Objects (PDO) ODBC support
+Summary(pl.UTF-8): Moduł PHP Data Objects (PDO) z obsługą ODBC
+Group: Libraries
+URL: http://www.php.net/manual/en/ref.pdo-odbc.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-pdo = %{epoch}:%{version}-%{release}
+Provides: php(pdo-odbc)
+Obsoletes: php-pecl-PDO_ODBC
+
+%description pdo-odbc
+This is a dynamic shared object (DSO) for PHP that will add PDO ODBC
+support.
+
+%description pdo-odbc -l pl.UTF-8
+Moduł dla PHP dodający obsługę baz danych ODBC za pośrednictwem
+interfejsu PDO.
+
+%package pdo-pgsql
+Summary: PHP Data Objects (PDO) PostgreSQL support
+Summary(pl.UTF-8): Moduł PHP Data Objects (PDO) z obsługą PostgreSQL-a
+Group: Libraries
+URL: http://www.php.net/manual/en/ref.pdo-pgsql.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-pdo = %{epoch}:%{version}-%{release}
+Provides: php(pdo-pgsql)
+Provides: php-pecl-PDO_PGSQL
+Obsoletes: php-pecl-PDO_PGSQL < 4:5.2.1-2
+
+%description pdo-pgsql
+This is a dynamic shared object (DSO) for PHP that will add PDO
+PostgreSQL support.
+
+%description pdo-pgsql -l pl.UTF-8
+Moduł dla PHP dodający obsługę baz danych PostgreSQL za pośrednictwem
+interfejsu PDO.
+
+%package pdo-sqlite
+Summary: PHP Data Objects (PDO) SQLite support
+Summary(pl.UTF-8): Moduł PHP Data Objects (PDO) z obsługą SQLite
+Group: Libraries
+URL: http://www.php.net/manual/en/ref.pdo-sqlite.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-pdo = %{epoch}:%{version}-%{release}
+Provides: php(pdo-sqlite)
+Obsoletes: php-pecl-PDO_SQLITE
+
+%description pdo-sqlite
+This is a dynamic shared object (DSO) for PHP that will add PDO SQLite
+support.
+
+%description pdo-sqlite -l pl.UTF-8
+Moduł dla PHP dodający obsługę baz danych SQLite za pośrednictwem
+interfejsu PDO.
+
+%package pgsql
+Summary: PostgreSQL database module for PHP
+Summary(pl.UTF-8): Moduł bazy danych PostgreSQL dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.pgsql.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(pgsql)
+
+%description pgsql
+This is a dynamic shared object (DSO) for PHP that will add PostgreSQL
+database support.
+
+%description pgsql -l pl.UTF-8
+Moduł PHP umożliwiający dostęp do bazy danych PostgreSQL.
+
+%description pgsql -l pt_BR.UTF-8
+Um módulo para aplicações PHP que usam bancos de dados postgresql.
+
+%package phar
+Summary: phar database module for PHP
+Summary(pl.UTF-8): Moduł phar dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.phar.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-spl = %{epoch}:%{version}-%{release}
+Provides: php(phar)
+
+%description phar
+This is a dynamic shared object (DSO) for PHP that will add phar
+archive a support.
+
+%description phar -l pl.UTF-8
+Moduł PHP umożliwiający dostęp do achiwów .phar.
+
+%package posix
+Summary: POSIX extension module for PHP
+Summary(pl.UTF-8): Moduł POSIX dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.posix.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(posix)
+
+%description posix
+This is a dynamic shared object (DSO) for PHP that will add POSIX
+functions support to PHP.
+
+%description posix -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z funkcji POSIX.
+
+%package pspell
+Summary: pspell extension module for PHP
+Summary(pl.UTF-8): Moduł pspell dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.pspell.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(pspell)
+
+%description pspell
+This is a dynamic shared object (DSO) for PHP that will add pspell
+support to PHP. It allows to check the spelling of a word and offer
+suggestions.
+
+%description pspell -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z pspella. Pozwala on na
+sprawdzanie pisowni słowa i sugerowanie poprawek.
+
+%package readline
+Summary: readline extension module for PHP
+Summary(pl.UTF-8): Moduł readline dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.readline.php
+Requires: %{name}-cli = %{epoch}:%{version}-%{release}
+Provides: php(readline)
+
+%description readline
+This PHP module adds support for readline functions (only for cli and
+cgi SAPIs).
+
+%description readline -l pl.UTF-8
+Moduł PHP dodający obsługę funkcji readline (tylko do SAPI cli i cgi).
+
+%package recode
+Summary: recode extension module for PHP
+Summary(pl.UTF-8): Moduł recode dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.recode.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: recode >= 3.5d-3
+Provides: php(recode)
+
+%description recode
+This is a dynamic shared object (DSO) for PHP that will add recode
+support.
+
+%description recode -l pl.UTF-8
+Moduł PHP dodający możliwość konwersji kodowania plików (poprzez
+bibliotekę recode).
+
+%package session
+Summary: session extension module for PHP
+Summary(pl.UTF-8): Moduł session dla PHP
+Group: Libraries
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-spl = %{epoch}:%{version}-%{release}
+Suggests: %{name}-hash = %{epoch}:%{version}-%{release}
+Provides: php(session)
+
+%description session
+This is a dynamic shared object (DSO) for PHP that will add session
+support.
+
+%description session -l pl.UTF-8
+Moduł PHP dodający obsługę sesji.
+
+%package shmop
+Summary: Shared Memory Operations extension module for PHP
+Summary(pl.UTF-8): Moduł shmop dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.shmop.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(shmop)
+
+%description shmop
+This is a dynamic shared object (DSO) for PHP that will add Shared
+Memory Operations support.
+
+%description shmop -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z pamięci dzielonej.
+
+%package simplexml
+Summary: Simple XML extension module for PHP
+Summary(pl.UTF-8): Moduł prostego rozszerzenia XML dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.simplexml.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-spl = %{epoch}:%{version}-%{release}
+Provides: php(simplexml)
+
+%description simplexml
+This is a dynamic shared object (DSO) for PHP that will add Simple XML
+support.
+
+%description simplexml -l pl.UTF-8
+Moduł PHP dodający obsługę prostego XML-a.
+
+%package snmp
+Summary: SNMP extension module for PHP
+Summary(pl.UTF-8): Moduł SNMP dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.snmp.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-sockets = %{epoch}:%{version}-%{release}
+Provides: php(snmp)
+
+%description snmp
+This is a dynamic shared object (DSO) for PHP that will add SNMP
+support.
+
+%description snmp -l pl.UTF-8
+Moduł PHP dodający obsługę SNMP.
+
+%package soap
+Summary: soap extension module for PHP
+Summary(pl.UTF-8): Moduł soap dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.soap.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(soap)
+
+%description soap
+This is a dynamic shared object (DSO) for PHP that will add SOAP/WSDL
+support.
+
+%description soap -l pl.UTF-8
+Moduł PHP dodający obsługę SOAP/WSDL.
+
+%package sockets
+Summary: sockets extension module for PHP
+Summary(pl.UTF-8): Moduł socket dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.sockets.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(sockets)
+
+%description sockets
+This is a dynamic shared object (DSO) for PHP that will add sockets
+support.
+
+%description sockets -l pl.UTF-8
+Moduł PHP dodający obsługę gniazdek.
+
+%package spl
+Summary: Standard PHP Library module for PHP
+Summary(pl.UTF-8): Moduł biblioteki standardowej (Standard PHP Library) dla PHP
+Group: Libraries
+URL: http://php.net/manual/en/book.spl.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-pcre = %{epoch}:%{version}-%{release}
+Requires: %{name}-simplexml = %{epoch}:%{version}-%{release}
+Provides: php(spl)
+
+%description spl
+This is a dynamic shared object (DSO) for PHP that will add Standard
+PHP Library support.
+
+%description spl -l pl.UTF-8
+Moduł PHP z biblioteką standardową PHP (SPL - Standard PHP Library).
+
+%package sqlite
+Summary: SQLite extension module for PHP
+Summary(pl.UTF-8): Moduł SQLite dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.sqlite.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-pdo = %{epoch}:%{version}-%{release}
+Requires: %{name}-spl = %{epoch}:%{version}-%{release}
+Provides: php(sqlite)
+
+%description sqlite
+SQLite is a C library that implements an embeddable SQL database
+engine. Programs that link with the SQLite library can have SQL
+database access without running a separate RDBMS process.
+
+SQLite is not a client library used to connect to a big database
+server. SQLite is the server. The SQLite library reads and writes
+directly to and from the database files on disk.
+
+%description sqlite -l pl.UTF-8
+SQLite jest napisaną w C biblioteką implementującą osadzalny silnik
+bazodanowy SQL. Program linkujący się z biblioteką SQLite może mieć
+dostęp do bazy SQL bez potrzeby uruchamiania dodatkowego procesu
+RDBMS.
+
+SQLite to nie klient baz danych - biblioteka nie łączy się z serwerami
+baz danych. SQLite sam jest serwerem. Biblioteka SQLite czyta i
+zapisuje dane bezpośrednio z/do plików baz danych znajdujących się na
+dysku.
+
+%package sqlite3
+Summary: SQLite3 extension module for PHP
+Summary(pl.UTF-8): Moduł SQLite3 dla PHP
+Group: Libraries
+URL: http://php.net/manual/en/book.sqlite3.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(sqlite3)
+
+%description sqlite3
+SQLite is a C library that implements an embeddable SQL database
+engine. Programs that link with the SQLite library can have SQL
+database access without running a separate RDBMS process.
+
+SQLite is not a client library used to connect to a big database
+server. SQLite is the server. The SQLite library reads and writes
+directly to and from the database files on disk.
+
+%description sqlite3 -l pl.UTF-8
+SQLite jest napisaną w C biblioteką implementującą osadzalny silnik
+bazodanowy SQL. Program linkujący się z biblioteką SQLite może mieć
+dostęp do bazy SQL bez potrzeby uruchamiania dodatkowego procesu
+RDBMS.
+
+SQLite to nie klient baz danych - biblioteka nie łączy się z serwerami
+baz danych. SQLite sam jest serwerem. Biblioteka SQLite czyta i
+zapisuje dane bezpośrednio z/do plików baz danych znajdujących się na
+dysku.
+
+%package sybase-ct
+Summary: Sybase-CT extension module for PHP
+Summary(pl.UTF-8): Moduł Sybase-CT dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.sybase.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(sybase-ct)
+Obsoletes: php-sybase
+
+%description sybase-ct
+This is a dynamic shared object (DSO) for PHP that will add Sybase and
+MS SQL databases support through CT-lib.
+
+%description sybase-ct -l pl.UTF-8
+Moduł PHP dodający obsługę baz danych Sybase oraz MS SQL poprzez
+CT-lib.
+
+%package sysvmsg
+Summary: SysV msg extension module for PHP
+Summary(pl.UTF-8): Moduł SysV msg dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.sem.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(sysvmsg)
+
+%description sysvmsg
+This is a dynamic shared object (DSO) for PHP that will add SysV
+message queues support.
+
+%description sysvmsg -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z kolejek komunikatów SysV.
+
+%package sysvsem
+Summary: SysV sem extension module for PHP
+Summary(pl.UTF-8): Moduł SysV sem dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.sem.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(sysvsem)
+
+%description sysvsem
+This is a dynamic shared object (DSO) for PHP that will add SysV
+semaphores support.
+
+%description sysvsem -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z semaforów SysV.
+
+%package sysvshm
+Summary: SysV shm extension module for PHP
+Summary(pl.UTF-8): Moduł SysV shm dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.shmop.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(sysvshm)
+
+%description sysvshm
+This is a dynamic shared object (DSO) for PHP that will add SysV
+Shared Memory support.
+
+%description sysvshm -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z pamięci dzielonej SysV.
+
+%package tests
+Summary: Contains unit test files for PHP and extensions
+Summary(pl.UTF-8): Zawiera pliki testów jednostkowych dla PHP i rozszerzeń
+Group: Libraries
+URL: http://qa.php.net/
+Requires: %{name}-cli
+
+%description tests
+This package contains unit tests for PHP and it's extensions.
+
+%description tests -l pl.UTF-8
+Ten pakiet zawiera pliki testów jednostkowych dla PHP i rozszerzeń
+
+%package tidy
+Summary: Tidy extension module for PHP
+Summary(pl.UTF-8): Moduł Tidy dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.tidy.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: tidy
+Provides: php(tidy)
+
+%description tidy
+This is a dynamic shared object (DSO) for PHP that will add Tidy
+support.
+
+%description tidy -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z tidy.
+
+%package tokenizer
+Summary: tokenizer extension module for PHP
+Summary(pl.UTF-8): Moduł rozszerzenia tokenizer dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.tokenizer.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(tokenizer)
+
+%description tokenizer
+This is a dynamic shared object (DSO) for PHP that will add tokenizer
+support.
+
+%description tokenizer -l pl.UTF-8
+Moduł PHP dodający obsługę tokenizera do PHP.
+
+%package wddx
+Summary: wddx extension module for PHP
+Summary(pl.UTF-8): Moduł wddx dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.wddx.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+# - wddx doesn't require session as it's disabled at compile time:
+# if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
+# see also php.spec#rev1.120.2.22
+#Requires: %{name}-session = %{epoch}:%{version}-%{release}
+Requires: %{name}-xml = %{epoch}:%{version}-%{release}
+Provides: php(wddx)
+
+%description wddx
+This is a dynamic shared object (DSO) for PHP that will add wddx
+support.
+
+%description wddx -l pl.UTF-8
+Moduł PHP umożliwiający korzystanie z wddx.
+
+%package xml
+Summary: XML extension module for PHP
+Summary(pl.UTF-8): Moduł XML dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.xml.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(xml)
+
+%description xml
+This is a dynamic shared object (DSO) for PHP that will add XML
+support. This extension lets you create XML parsers and then define
+handlers for different XML events.
+
+%description xml -l pl.UTF-8
+Moduł PHP umożliwiający parsowanie plików XML i obsługę zdarzeń
+związanych z tymi plikami. Pozwala on tworzyć analizatory XML-a i
+następnie definiować procedury obsługi dla różnych zdarzeń XML.
+
+%package xmlreader
+Summary: XML Reader extension module for PHP
+Summary(pl.UTF-8): Moduł XML Reader dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.xmlreader.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Suggests: %{name}-dom = %{epoch}:%{version}-%{release}
+Provides: php(xmlreader)
+
+%description xmlreader
+This is a dynamic shared object (DSO) for PHP that will add XML Reader
+support. The XMLReader extension is an XML Pull parser. The reader
+acts as a cursor going forward on the document stream and stopping at
+each node on the way.
+
+%description xmlreader -l pl.UTF-8
+Moduł PHP umożliwiający analizę plików XML w trybie Pull. Czytnik
+działa jako kursor przechodzący przez strumień dokumentu i
+zatrzymujący się na każdym węźle po drodze.
+
+%package xmlrpc
+Summary: xmlrpc extension module for PHP
+Summary(pl.UTF-8): Moduł xmlrpc dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.xmlrpc.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-xml = %{epoch}:%{version}-%{release}
+Provides: php(xmlrpc)
+
+%description xmlrpc
+This is a dynamic shared object (DSO) for PHP that will add XMLRPC
+support.
+
+%description xmlrpc -l pl.UTF-8
+Moduł PHP dodający obsługę XMLRPC.
+
+%package xmlwriter
+Summary: Fast, non-cached, forward-only means to write XML data
+Summary(pl.UTF-8): Szybka, nie cachowana metoda zapisu danych w formacie XML
+Group: Libraries
+URL: http://www.php.net/manual/en/book.xmlwriter.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(xmlwriter)
+Obsoletes: php-pecl-xmlwriter
+
+%description xmlwriter
+This extension wraps the libxml xmlWriter API. Represents a writer
+that provides a non-cached, forward-only means of generating streams
+or files containing XML data.
+
+%description xmlwriter -l pl.UTF-8
+To rozszerzenie obudowuje API xmlWriter z libxml. Reprezentuje obsługę
+zapisu dostarczającą nie cachowanych metod generowania strumieni lub
+plików zawierających dane XML.
+
+%package xsl
+Summary: xsl extension module for PHP
+Summary(pl.UTF-8): Moduł xsl dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.xsl.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Requires: %{name}-dom = %{epoch}:%{version}-%{release}
+Requires: libxslt >= 1.0.18
+# actually not true, functionality is similar, but API differs
+Provides: php(xsl)
+Obsoletes: php-xslt <= 3:4.3.8-1
+
+%description xsl
+This is a dynamic shared object (DSO) for PHP that will add new XSL
+support (using libxslt).
+
+%description xsl -l pl.UTF-8
+Moduł PHP dodający nową obsługę XSLT (przy użyciu libxslt).
+
+%package zip
+Summary: Zip management extension
+Summary(pl.UTF-8): Zarządzanie archiwami zip
+Group: Libraries
+URL: http://www.php.net/manual/en/book.zip.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(zip)
+Obsoletes: php-pecl-zip
+
+%description zip
+Zip is an extension to create, modify and read zip files.
+
+%description zip -l pl.UTF-8
+Zip jest rozszerzeniem umożliwiającym tworzenie, modyfikację oraz
+odczyt archiwów zip.
+
+%package zlib
+Summary: Zlib extension module for PHP
+Summary(pl.UTF-8): Moduł zlib dla PHP
+Group: Libraries
+URL: http://www.php.net/manual/en/book.zlib.php
+Requires: %{name}-common = %{epoch}:%{version}-%{release}
+Provides: php(zlib)
+
+%description zlib
+This is a dynamic shared object (DSO) for PHP that will add zlib
+compression support to PHP.
+
+%description zlib -l pl.UTF-8
+Moduł PHP umożliwiający używanie kompresji zlib.
+
+%prep
+%setup -q
+# prep for suhosin patch
+%{__sed} -i -e 's,\r$,,' Zend/Zend.dsp Zend/ZendTS.dsp
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch8 -p1
+%patch7 -p1
+%patch9 -p1
+cp php.ini-production php.ini
+%patch10 -p1
+%if %{with type_hints}
+%patch12 -p0
+%endif
+%patch14 -p1
+%patch15 -p1
+%patch17 -p1
+%patch18 -p1
+%if %{with system_gd}
+%patch19 -p1
+%endif
+%patch20 -p1
+%patch21 -p1
+%patch22 -p1
+%patch23 -p1
+%patch24 -p1
+%patch25 -p1
+%patch26 -p1
+%patch27 -p1
+%patch29 -p1
+%patch31 -p1
+%patch32 -p1
+%if "%{pld_release}" != "ac"
+%patch34 -p1
+%endif
+%patch35 -p1
+%patch36 -p1
+%patch37 -p1
+%patch38 -p1
+%patch39 -p1
+%if %{with fpm}
+%patch41 -p1
+%patch42 -p1
+%endif
+%patch43 -p1
+%patch44 -p1
+%patch45 -p1
+%patch46 -p1
+%if %{with suhosin}
+%patch47 -p1
+%endif
+%patch49 -p1
+%patch50 -p1
+%patch51 -p1
+%patch52 -p1
+%patch53 -p1
+%patch54 -p1
+%undos ext/spl/tests/SplFileInfo_getInode_basic.phpt
+%patch55 -p1
+%patch57 -p1
+%patch59 -p1
+%patch60 -p1
+%patch61 -p1
+%patch62 -p1
+%patch63 -p1
+%patch64 -p1
+%{__rm} -r sapi/litespeed
+gzip -dc %{SOURCE15} | tar xf - -C sapi/
+
+%if "%{pld_release}" != "ac"
+sed -i -e '/PHP_ADD_LIBRARY_WITH_PATH/s#xmlrpc,#xmlrpc-epi,#' ext/xmlrpc/config.m4
+%endif
+
+# cleanup backups after patching
+find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f
+
+# conflict seems to be resolved by recode patches
+%{__rm} ext/recode/config9.m4
+
+# remove all bundled libraries not to link with them accidentally
+#%{__rm} -r ext/sqlite/libsqlite
+%{__rm} -r ext/sqlite3/libsqlite
+#%{__rm} -r ext/bcmath/libbcmath
+#%{__rm} -r ext/date/lib
+#%{__rm} -r ext/fileinfo/libmagic
+#%{__rm} -r ext/dba/libcdb
+#%{__rm} -r ext/dba/libflatfile
+#%{__rm} -r ext/dba/libinifile
+#%{__rm} -r ext/gd/libgd
+#%{__rm} -r ext/mbstring/libmbfl
+#%{__rm} -r ext/mbstring/oniguruma
+%{__rm} -r ext/pcre/pcrelib
+#%{__rm} -r ext/soap/interop
+%{__rm} -r ext/xmlrpc/libxmlrpc
+#%{__rm} -r ext/zip/lib
+
+cp -af Zend/LICENSE{,.Zend}
+install -p %{SOURCE13} dep-tests.sh
+
+# breaks build
+sed -i -e 's#-fvisibility=hidden##g' configure*
+
+# disable broken tests
+# says just "Terminated" twice and fails
+mv sapi/cli/tests/022.phpt{,.broken}
+
+# php-5.3.3/ext/standard/tests/file/statpage.phpt
+%{__rm} ext/standard/tests/file/statpage.phpt
+
+# idiotic test, it will fail if somebody else makes space on disk or if disk
+# space is not yet allocated (xfs). report upstream to advice bogus test is
+# probably pointless.
+%{__rm} ext/standard/tests/file/disk_free_space_basic.phpt
+
+sh -xe %{_sourcedir}/skip-tests.sh
+
+%build
+API=$(awk '/#define PHP_API_VERSION/{print $3}' main/php.h)
+if [ $API != %{php_api_version} ]; then
+ echo "Set %%define php_api_version to $API and re-run."
+ exit 1
+fi
+
+API=$(awk '/#define ZEND_MODULE_API_NO/{print $3}' Zend/zend_modules.h)
+if [ $API != %{zend_module_api} ]; then
+ echo "Set %%define zend_module_api to $API and re-run."
+ exit 1
+fi
+
+API=$(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' Zend/zend_extensions.h)
+if [ $API != %{zend_extension_api} ]; then
+ echo "Set %%define zend_extension_api to $API and re-run."
+ exit 1
+fi
+
+export EXTENSION_DIR="%{php_extensiondir}"
+# configure once (for faster debugging purposes)
+if [ ! -f _built-conf ]; then
+ # now remove Makefile copies
+ rm -f Makefile.{cgi-fcgi,fpm,cli,apxs1,apxs2,litespeed}
+ %{__libtoolize}
+ %{__aclocal}
+ cp -f /usr/share/automake/config.* .
+ ./buildconf --force
+ touch _built-conf
+fi
+export PROG_SENDMAIL="/usr/lib/sendmail"
+export CPPFLAGS="-DDEBUG_FASTCGI -DHAVE_STRNDUP %{rpmcppflags} \
+ -I%{_includedir}/xmlrpc-epi"
+
+sapis="
+cli
+%if %{with cgi}
+cgi-fcgi
+%endif
+%if %{with litespeed}
+litespeed
+%endif
+%if %{with fpm}
+fpm
+%endif
+%if %{with apache1}
+apxs1
+%endif
+%if %{with apache2}
+apxs2
+%endif
+"
+for sapi in $sapis; do
+ : SAPI $sapi
+ # skip if already configured (for faster debugging purposes)
+ [ -f Makefile.$sapi ] && continue
+
+ sapi_args=''
+ case $sapi in
+ cgi-fcgi)
+ sapi_args='--disable-cli'
+ ;;
+ cli)
+ sapi_args='--disable-cgi %{?with_gcov:--enable-gcov}'
+ ;;
+ fpm)
+ sapi_args='--disable-cli --enable-fpm'
+ ;;
+ apxs1)
+ ver=$(rpm -q --qf '%{V}' apache1-devel)
+ sapi_args="--disable-cli --with-apxs=%{apxs1} --with-apache-version=$ver"
+ ;;
+ apxs2)
+ ver=$(rpm -q --qf '%{V}' apache-devel)
+ sapi_args="--disable-cli --with-apxs2=%{apxs2} --with-apache-version=$ver"
+ ;;
+ litespeed)
+ sapi_args='--with-litespeed'
+ ;;
+ esac
+
+ %configure \
+ $sapi_args \
+%if "%{!?configure_cache:0}%{?configure_cache}" == "0"
+ --cache-file=config.cache \
+%endif
+ --with-libdir=%{_lib} \
+ --with-config-file-path=%{_sysconfdir} \
+ --with-config-file-scan-dir=%{_sysconfdir}/conf.d \
+ --with-exec-dir=%{_bindir} \
+ --with-system-tzdata \
+ --%{!?debug:dis}%{?debug:en}able-debug \
+ %{?with_zts:--enable-maintainer-zts} \
+ --enable-inline-optimization \
+ --enable-bcmath=shared \
+ --enable-calendar=shared \
+ --enable-ctype=shared \
+ --enable-dba=shared \
+ --enable-dom=shared \
+ --enable-exif=shared \
+ --enable-fileinfo=shared \
+ --enable-ftp=shared \
+ --enable-gd-native-ttf \
+ --enable-intl=shared \
+ --enable-libxml \
+ --enable-magic-quotes \
+ --enable-mbstring=shared,all \
+ --enable-mbregex \
+ --enable-pcntl=shared \
+ --enable-pdo=shared \
+ --enable-json=shared \
+ --enable-hash=shared \
+ --enable-xmlwriter=shared \
+%if %{with fpm}
+ --with-fpm-user=http \
+ --with-fpm-group=http \
+%endif
+%if %{with mssql} || %{with sybase_ct}
+ --with-pdo-dblib=shared \
+%endif
+%if %{with interbase} && %{without interbase_inst}
+ --with-pdo-firebird=shared,/usr \
+%endif
+ %{?with_mhash:--with-mhash=yes} \
+ --with-mysql-sock=/var/lib/mysql/mysql.sock \
+ --with-pdo-mysql=shared%{?with_mysqlnd:,mysqlnd} \
+ %{?with_oci8:--with-pdo-oci=shared%{?with_instantclient:,instantclient,%{_libdir}}} \
+ %{?with_odbc:--with-pdo-odbc=shared,unixODBC,/usr} \
+ %{?with_pgsql:--with-pdo-pgsql=shared} \
+ %{?with_pdo_sqlite:--with-pdo-sqlite=shared,/usr} \
+ --without-libexpat-dir \
+ --enable-posix=shared \
+ --enable-shared \
+ --enable-session=shared \
+ --enable-shmop=shared \
+ --enable-simplexml=shared \
+ --enable-sysvmsg=shared \
+ --enable-sysvsem=shared \
+ --enable-sysvshm=shared \
+ --enable-safe-mode \
+ --enable-soap=shared \
+ --enable-sockets=shared \
+ --enable-tokenizer=shared \
+ --enable-ucd-snmp-hack \
+ %{?with_wddx:--enable-wddx=shared} \
+ --enable-xml=shared \
+ --enable-xmlreader=shared \
+ --with-bz2=shared \
+ %{__with_without curl curl shared} \
+ --with-db4 \
+ --with-iconv=shared \
+ --with-freetype-dir=shared \
+ --with-gettext=shared \
+ --with-gd=shared%{?with_system_gd:,/usr} \
+ --with-gdbm \
+ --with-gmp=shared \
+ %{?with_imap:--with-imap=shared --with-imap-ssl} \
+ %{?with_interbase:--with-interbase=shared%{!?with_interbase_inst:,/usr}} \
+ --with-jpeg-dir=/usr \
+ %{?with_ldap:--with-ldap=shared --with-ldap-sasl} \
+ --with-mcrypt=shared \
+ %{?with_mm:--with-mm} \
+ %{?with_mssql:--with-mssql=shared} \
+ %{?with_mysqlnd:--with-mysqlnd=shared} \
+ --with-mysql=shared%{?with_mysqlnd:,mysqlnd} \
+ %{?with_mysqli:--with-mysqli=shared%{?with_mysqlnd:,mysqlnd}} \
+ %{?with_oci8:--with-oci8=shared%{?with_instantclient:,instantclient,%{_libdir}}} \
+ %{?with_openssl:--with-openssl=shared} \
+ %{?with_kerberos5:--with-kerberos} \
+ %{__with_without pcre pcre-regex /usr} \
+ %{__enable_disable filter filter shared} \
+ --with-pear=%{php_pear_dir} \
+ %{__with_without pgsql pgsql shared,/usr} \
+ %{__enable_disable phar phar shared} \
+ --with-png-dir=/usr \
+ %{?with_pspell:--with-pspell=shared} \
+ --with-readline=shared \
+ %{?with_recode:--with-recode=shared} \
+ --with-regex=system \
+ %{?with_snmp:--with-snmp=shared} \
+ %{?with_sybase_ct:--with-sybase-ct=shared,/usr} \
+ %{!?with_sqlite2:--without-sqlite}%{?with_sqlite2:--with-sqlite=shared,/usr --enable-sqlite-utf8} \
+ %{!?with_pdo_sqlite:--without-pdo-sqlite} \
+ %{__with_without sqlite3 sqlite3 shared,/usr} \
+ --with-t1lib=shared \
+ %{?with_tidy:--with-tidy=shared} \
+ %{?with_odbc:--with-unixODBC=shared,/usr} \
+ %{__with_without xmlrpc xmlrpc shared,/usr} \
+ --with-xsl=shared \
+ --with-zlib=shared \
+ --with-zlib-dir=shared,/usr \
+ --enable-zip=shared,/usr \
+
+ # save for debug
+ cp -f Makefile Makefile.$sapi
+ cp -f main/php_config.h php_config.h.$sapi
+ cp -f config.log config.log.$sapi
+done
+
+# as we build each SAPI in own make, adjust php-config.in forehead
+sapis=$(awk '/^PHP_SAPI = /{print $3}' Makefile.* | sort -u | xargs)
+sed -i -e "s,@PHP_INSTALLED_SAPIS@,$sapis," "scripts/php-config.in"
+
+# must make libphp_common first, so modules can link against it.
+cp -af php_config.h.cli main/php_config.h
+cp -af Makefile.cli Makefile
+%{__make} libphp_common.la
+%{__make} build-modules
+
+%if %{with apache1}
+%{__make} libtool-sapi LIBTOOL_SAPI=sapi/apache/libphp5.la -f Makefile.apxs1
+%endif
+
+%if %{with apache2}
+%{__make} libtool-sapi LIBTOOL_SAPI=sapi/apache2handler/libphp5.la -f Makefile.apxs2
+%endif
+
+%if %{with litespeed}
+%{__make} -f Makefile.litespeed
+%endif
+
+# CGI/FCGI
+%if %{with cgi}
+cp -af php_config.h.cgi-fcgi main/php_config.h
+%{__make} -f Makefile.cgi-fcgi
+[ "$(echo '<?=php_sapi_name();' | ./sapi/cgi/php-cgi -qn)" = cgi-fcgi ] || exit 1
+%endif
+
+# PHP FPM
+%if %{with fpm}
+cp -af php_config.h.fpm main/php_config.h
+%{__make} -f Makefile.fpm
+ ./sapi/fpm/php-fpm -qn -m > /dev/null
+%endif
+
+# CLI
+cp -af php_config.h.cli main/php_config.h
+%{__make} -f Makefile.cli
+[ "$(echo '<?=php_sapi_name();' | ./sapi/cli/php -qn)" = cli ] || exit 1
+
+# check for stupid xml parse breakage where < and > just get lost in parse result
+./sapi/cli/php -n -dextension_dir=modules -dextension=xml.so -r '$p = xml_parser_create(); xml_parse_into_struct($p, "<x><</x>", $vals, $index); exit((int )empty($vals[0]["value"]));'
+
+# Generate stub .ini files for each extension
+rm -rf conf.d
+install -d conf.d
+generate_inifiles() {
+ for so in modules/*.so; do
+ mod=$(basename $so .so)
+ conf="$mod.ini"
+ # xml needs to be loaded before wddx
+ [ "$mod" = "wddx" ] && conf="xml_$mod.ini"
+ # pre needs to be loaded before SPL
+ [ "$mod" = "pcre" ] && conf="PCRE.ini"
+ # spl needs to be loaded before mysqli
+ [ "$mod" = "spl" ] && conf="SPL.ini"
+ # session needs to be loaded before php-pecl-http, php-pecl-memcache, php-pecl-session_mysql
+ [ "$mod" = "session" ] && conf="Session.ini"
+ # mysqlnd needs to be loaded before mysql,mysqli,pdo_mysqli
+ [ "$mod" = "mysqlnd" ] && conf="MySQLND.ini"
+ echo "+ $conf"
+ cat > conf.d/$conf <<-EOF
+ ; Enable $mod extension module
+ extension=$mod.so
+ EOF
+ done
+}
+generate_inifiles
+
+# Check that the module inner-dependencies are intact
+PHP=./sapi/cli/php EXTENSION_DIR=modules CONFIG_DIR=conf.d ./dep-tests.sh > dep-tests.log
+if grep -v OK dep-tests.log; then
+ echo >&2 "The results above were not expected"
+ exit 1
+fi
+
+%if %{with gcov}
+# Use CLI SAPI
+cp -af php_config.h.cli main/php_config.h
+cp -af Makefile.cli Makefile
+%{__make} lcov
+# you really don't want to package result of gcov build
+exit 1
+%endif
+
+%if %{with tests}
+# Run tests, using the CLI SAPI
+cp -af php_config.h.cli main/php_config.h
+cp -af Makefile.cli Makefile
+
+cat <<'EOF' > run-tests.sh
+#!/bin/sh
+export NO_INTERACTION=1 REPORT_EXIT_STATUS=1 MALLOC_CHECK_=2
+unset TZ LANG LC_ALL || :
+%{__make} test \
+ EXTENSION_DIR=modules \
+ PHP_TEST_SHARED_SYSTEM_EXTENSIONS= \
+ RUN_TESTS_SETTINGS="-q $*"
+EOF
+chmod +x run-tests.sh
+./run-tests.sh -w failed.log -s test.log
+
+# collect failed tests into cleanup script used in prep.
+sed -ne '/FAILED TEST SUMMARY/,/^===/p' test.log | sed -e '1,/^---/d;/^===/,$d' > tests-failed.log
+sed -ne '/\[.*\]/{s/\(.*\) \[\(.*\)\]/# \1\nmv \2{,.skip}/p}' tests-failed.log \
+ >> %{_sourcedir}/skip-tests.sh
+
+failed=$(wc -l < tests-failed.log)
+if [ "$failed" != 0 ]; then
+ exit 1
+fi
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT{%{_libdir}/{php,apache{,1}},%{_sysconfdir}/{apache,cgi}} \
+ $RPM_BUILD_ROOT{%{_sbindir},%{_bindir}} \
+ $RPM_BUILD_ROOT/etc/{apache/conf.d,httpd/conf.d} \
+ $RPM_BUILD_ROOT%{_mandir}/man{1,8} \
+
+cp -af php_config.h.cli main/php_config.h
+cp -af Makefile.cli Makefile
+%{__make} install \
+ INSTALL_ROOT=$RPM_BUILD_ROOT
+
+# make link relative
+ln -sfn phar.phar $RPM_BUILD_ROOT%{_bindir}/phar
+
+# install Apache1 DSO module
+%if %{with apache1}
+libtool --mode=install install sapi/apache/libphp5.la $RPM_BUILD_ROOT%{_libdir}/apache1
+%endif
+
+# install Apache2 DSO module
+%if %{with apache2}
+libtool --mode=install install sapi/apache2handler/libphp5.la $RPM_BUILD_ROOT%{_libdir}/apache
+%endif
+
+# install litespeed sapi
+%if %{with litespeed}
+libtool --mode=install install sapi/litespeed/php $RPM_BUILD_ROOT%{_sbindir}/php.litespeed
+%endif
+
+libtool --mode=install install libphp_common.la $RPM_BUILD_ROOT%{_libdir}
+# fix install paths, avoid evil rpaths
+sed -i -e "s|^libdir=.*|libdir='%{_libdir}'|" $RPM_BUILD_ROOT%{_libdir}/libphp_common.la
+# better solution?
+sed -i -e 's|libphp_common.la|$(libdir)/libphp_common.la|' $RPM_BUILD_ROOT%{_libdir}/php/build/acinclude.m4
+
+# install CGI/FCGI
+%if %{with cgi}
+libtool --mode=install install sapi/cgi/php-cgi $RPM_BUILD_ROOT%{_bindir}/php.cgi
+ln -sf php.cgi $RPM_BUILD_ROOT%{_bindir}/php.fcgi
+cp -a %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/php-cgi-fcgi.ini
+%endif
+
+# install FCGI PM
+%if %{with fpm}
+install -d $RPM_BUILD_ROOT{%{_sysconfdir}/fpm.d,%{_sbindir}}
+libtool --mode=install install sapi/fpm/php-fpm $RPM_BUILD_ROOT%{_sbindir}
+cp -a sapi/fpm/php-fpm.8 $RPM_BUILD_ROOT%{_mandir}/man8
+cp -a sapi/fpm/php-fpm.conf $RPM_BUILD_ROOT%{_sysconfdir}
+install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
+install -p %{SOURCE10} $RPM_BUILD_ROOT/etc/rc.d/init.d/php-fpm
+install -d $RPM_BUILD_ROOT/etc/logrotate.d
+cp -a %{SOURCE11} $RPM_BUILD_ROOT/etc/logrotate.d/php-fpm
+%endif
+
+# install CLI
+libtool --mode=install install sapi/cli/php $RPM_BUILD_ROOT%{_bindir}/php.cli
+install sapi/cli/php.1 $RPM_BUILD_ROOT%{_mandir}/man1/php.1
+echo ".so php.1" >$RPM_BUILD_ROOT%{_mandir}/man1/php.cli.1
+ln -sf php.cli $RPM_BUILD_ROOT%{_bindir}/php
+
+sed -e 's#%{_prefix}/lib/php#%{_libdir}/php#g' php.ini > $RPM_BUILD_ROOT%{_sysconfdir}/php.ini
+
+cp -a %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/php-cli.ini
+cp -a %{SOURCE9} $RPM_BUILD_ROOT%{_sysconfdir}/browscap.ini
+
+%if %{with apache1}
+cp -a %{SOURCE2} $RPM_BUILD_ROOT/etc/apache/conf.d/70_mod_php.conf
+cp -a %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/php-apache.ini
+rm -f $RPM_BUILD_ROOT%{_libdir}/apache1/libphp5.la
+%endif
+
+%if %{with apache2}
+cp -a %{SOURCE2} $RPM_BUILD_ROOT/etc/httpd/conf.d/70_mod_php.conf
+cp -a %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/php-apache2handler.ini
+rm -f $RPM_BUILD_ROOT%{_libdir}/apache/libphp5.la
+%endif
+
+install -d $RPM_BUILD_ROOT%{_sysconfdir}/conf.d
+cp -a conf.d/*.ini $RPM_BUILD_ROOT%{_sysconfdir}/conf.d
+
+# per SAPI ini directories
+install -d $RPM_BUILD_ROOT%{_sysconfdir}/{cgi-fcgi,cli,apache,apache2handler}.d
+
+# for CLI SAPI only
+mv $RPM_BUILD_ROOT%{_sysconfdir}/{conf.d/readline.ini,cli.d}
+
+# use system automake and {lib,sh}tool
+%if "%{pld_release}" != "ac"
+ ln -snf /usr/share/automake/config.{guess,sub} $RPM_BUILD_ROOT%{_libdir}/php/build
+ for i in libtool.m4 lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4; do
+ ln -snf %{_aclocaldir}/${i} $RPM_BUILD_ROOT%{_libdir}/php/build
+ done
+ ln -snf %{_datadir}/libtool/config/ltmain.sh $RPM_BUILD_ROOT%{_libdir}/php/build
+%else
+ ln -snf %{_aclocaldir}/libtool.m4 $RPM_BUILD_ROOT%{_libdir}/php/build
+ ln -snf %{_datadir}/libtool/ltmain.sh $RPM_BUILD_ROOT%{_libdir}/php/build
+%endif
+ln -snf %{_bindir}/shtool $RPM_BUILD_ROOT%{_libdir}/php/build
+
+# for php-pecl-mailparse
+install -d $RPM_BUILD_ROOT%{_includedir}/php/ext/mbstring
+cp -a ext/mbstring/libmbfl/mbfl/*.h $RPM_BUILD_ROOT%{_includedir}/php/ext/mbstring
+
+# tests
+install -d $RPM_BUILD_ROOT%{php_data_dir}/tests/php
+install -p run-tests.php $RPM_BUILD_ROOT%{php_data_dir}/tests/php/run-tests.php
+cp -a tests/* $RPM_BUILD_ROOT%{php_data_dir}/tests/php
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post -n apache1-mod_php
+if [ "$1" = "1" ]; then
+ %service -q apache restart
+fi
+
+%postun -n apache1-mod_php
+if [ "$1" = "0" ]; then
+ %service -q apache restart
+fi
+
+%post -n apache-mod_php
+if [ "$1" = "1" ]; then
+ %service -q httpd restart
+fi
+
+%postun -n apache-mod_php
+if [ "$1" = "0" ]; then
+ %service -q httpd restart
+fi
+
+%pre fpm
+%useradd -u 51 -r -s /bin/false -c "HTTP User" -g http http
+
+%post fpm
+/sbin/chkconfig --add php-fpm
+%service php-fpm restart
+
+%preun fpm
+if [ "$1" = 0 ]; then
+ %service php-fpm stop
+ /sbin/chkconfig --del php-fpm
+fi
+
+%postun fpm
+if [ "$1" = "0" ]; then
+ %userremove http
+fi
+
+%post common
+# PHP 5.3 requires timezone being setup, try setup it from tzdata
+if ! grep -q '^date.timezone[[:space:]]*=' %{_sysconfdir}/php.ini && [ -f /etc/sysconfig/timezone ]; then
+ TIMEZONE=
+ . /etc/sysconfig/timezone
+ if [ "$TIMEZONE" ]; then
+ %{__sed} -i -e "s,^;date.timezone[[:space:]]*=.*,date.timezone = $TIMEZONE," %{_sysconfdir}/php.ini
+ fi
+fi
+
+%posttrans common
+# minimizing apache restarts logics. we restart webserver:
+#
+# 1. at the end of transaction. (posttrans, feature from rpm 4.4.2)
+# 2. first install of extension (post: $1 = 1)
+# 2. uninstall of extension (postun: $1 == 0)
+#
+# the strict internal deps between extensions (and apache modules) and
+# common package are very important for all this to work.
+
+# restart webserver at the end of transaction
+[ ! -f /etc/apache/conf.d/??_mod_php.conf ] || %service -q apache restart
+[ ! -f /etc/httpd/conf.d/??_mod_php.conf ] || %service -q httpd restart
+
+%if %{with apache1}
+%triggerpostun -n apache1-mod_php -- php < 4:5.0.4-9.11
+sed -i -e '
+ /^AddType application\/x-httpd-php \.php/s,^,#,
+ /^\(Add\|Load\)Module.*php5\.\(so\|c\)/d
+' /etc/apache/apache.conf
+%service -q apache restart
+%endif
+
+%if %{with apache2}
+%triggerpostun -n apache-mod_php -- php < 4:5.0.4-7.1
+# for fixed php-SAPI.ini, the poor php-apache.ini was never read for apache2
+if [ -f %{_sysconfdir}/php-apache.ini.rpmsave ]; then
+ cp -f %{_sysconfdir}/php-apache2handler.ini{,.rpmnew}
+ mv -f %{_sysconfdir}/php-apache.ini.rpmsave %{_sysconfdir}/php-apache2handler.ini
+fi
+%endif
+
+# common macros called at extension post/postun scriptlet
+%define extension_scripts() \
+%post %1 \
+if [ "$1" = "1" ]; then \
+ %php_webserver_restart \
+fi \
+\
+%postun %1 \
+if [ "$1" = "0" ]; then \
+ %php_webserver_restart \
+fi
+%{nil}
+
+# extension scripts defines
+%extension_scripts bcmath
+%extension_scripts bz2
+%extension_scripts calendar
+%extension_scripts ctype
+%extension_scripts curl
+%extension_scripts dba
+%extension_scripts dom
+%extension_scripts exif
+%extension_scripts fileinfo
+%extension_scripts filter
+%extension_scripts ftp
+%extension_scripts gd
+%extension_scripts gettext
+%extension_scripts gmp
+%extension_scripts hash
+%extension_scripts iconv
+%extension_scripts imap
+%extension_scripts interbase
+%extension_scripts intl
+%extension_scripts json
+%extension_scripts ldap
+%extension_scripts mbstring
+%extension_scripts mcrypt
+%extension_scripts mssql
+%extension_scripts mysql
+%extension_scripts mysqli
+%extension_scripts mysqlnd
+%extension_scripts oci8
+%extension_scripts odbc
+%extension_scripts openssl
+%extension_scripts pcre
+%extension_scripts pdo-dblib
+%extension_scripts pdo-firebird
+%extension_scripts pdo-mysql
+%extension_scripts pdo-odbc
+%extension_scripts pdo-pgsql
+%extension_scripts pdo-sqlite
+%extension_scripts pgsql
+%extension_scripts phar
+%extension_scripts posix
+%extension_scripts pspell
+%extension_scripts recode
+%extension_scripts session
+%extension_scripts shmop
+%extension_scripts snmp
+%extension_scripts soap
+%extension_scripts sockets
+%extension_scripts spl
+%extension_scripts sqlite
+%extension_scripts sqlite3
+%extension_scripts sybase-ct
+%extension_scripts sysvmsg
+%extension_scripts sysvsem
+%extension_scripts sysvshm
+%extension_scripts tidy
+%extension_scripts tokenizer
+%extension_scripts wddx
+%extension_scripts xml
+%extension_scripts xmlreader
+%extension_scripts xmlrpc
+%extension_scripts xmlwriter
+%extension_scripts xsl
+%extension_scripts zip
+%extension_scripts zlib
+
+%triggerun bcmath -- %{name}-bcmath < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*bcmath\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun calendar -- %{name}-calendar < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*calendar\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun ctype -- %{name}-ctype < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*ctype\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun curl -- %{name}-curl < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*curl\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun dba -- %{name}-dba < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*dba\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun dom -- %{name}-dom < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*dom\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun exif -- %{name}-exif < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*exif\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun ftp -- %{name}-ftp < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*ftp\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun gd -- %{name}-gd < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*gd\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun gettext -- %{name}-gettext < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*gettext\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun gmp -- %{name}-gmp < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*gmp\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun iconv -- %{name}-iconv < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*iconv\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun imap -- %{name}-imap < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*imap\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun interbase -- %{name}-interbase < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*interbase\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun ldap -- %{name}-ldap < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*ldap\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun mbstring -- %{name}-mbstring < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*mbstring\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun mcrypt -- %{name}-mcrypt < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*mcrypt\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun mssql -- %{name}-mssql < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*mssql\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun mysql -- %{name}-mysql < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*mysql\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun mysqli -- %{name}-mysqli < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*mysqli\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun oci8 -- %{name}-oci8 < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*oci8\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun odbc -- %{name}-odbc < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*odbc\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun openssl -- %{name}-openssl < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*openssl\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun pcntl -- %{name}-pcntl < 4:5.1.2-9.5
+if [ -f %{_sysconfdir}/php-cgi.ini ]; then
+ %{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*pcntl\.so/d' %{_sysconfdir}/php-cgi.ini
+fi
+if [ -f %{_sysconfdir}/php-cli.ini ]; then
+ %{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*pcntl\.so/d' %{_sysconfdir}/php-cli.ini
+fi
+
+%triggerun pcre -- %{name}-pcre < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*pcre\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun pgsql -- %{name}-pgsql < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*pgsql\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun posix -- %{name}-posix < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*posix\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun pspell -- %{name}-pspell < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*pspell\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun readline -- %{name}-readline < 4:5.1.2-9.5
+if [ -f %{_sysconfdir}/php-cgi.ini ]; then
+ %{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*readline\.so/d' %{_sysconfdir}/php-cgi.ini
+fi
+if [ -f %{_sysconfdir}/php-cli.ini ]; then
+ %{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*readline\.so/d' %{_sysconfdir}/php-cli.ini
+fi
+
+%triggerun recode -- %{name}-recode < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*recode\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun session -- %{name}-session < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*session\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun shmop -- %{name}-shmop < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*shmop\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun snmp -- %{name}-snmp < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*snmp\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun soap -- %{name}-soap < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*soap\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun sockets -- %{name}-sockets < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*sockets\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun sqlite -- %{name}-sqlite < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*sqlite\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun sybase-ct -- %{name}-sybase-ct < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*sybase-ct\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun sysvmsg -- %{name}-sysvmsg < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*sysvmsg\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun sysvsem -- %{name}-sysvsem < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*sysvsem\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun sysvshm -- %{name}-sysvshm < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*sysvshm\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun tidy -- %{name}-tidy < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*tidy\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun wddx -- %{name}-wddx < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*wddx\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun xml -- %{name}-xml < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*xml\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun xmlrpc -- %{name}-xmlrpc < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*xmlrpc\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun xsl -- %{name}-xsl < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*xsl\.so/d' %{_sysconfdir}/php.ini
+
+%triggerun zlib -- %{name}-zlib < 4:5.0.4-9.1
+%{__sed} -i -e '/^extension[[:space:]]*=[[:space:]]*zlib\.so/d' %{_sysconfdir}/php.ini
+
+%if %{with apache1}
+%files -n apache1-mod_php
+%defattr(644,root,root,755)
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/apache/conf.d/*_mod_php.conf
+%dir %{_sysconfdir}/apache.d
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php-apache.ini
+%attr(755,root,root) %{_libdir}/apache1/libphp5.so
+%endif
+
+%if %{with apache2}
+%files -n apache-mod_php
+%defattr(644,root,root,755)
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/httpd/conf.d/*_mod_php.conf
+%dir %{_sysconfdir}/apache2handler.d
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php-apache2handler.ini
+%attr(755,root,root) %{_libdir}/apache/libphp5.so
+%endif
+
+%if %{with litespeed}
+%files litespeed
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_sbindir}/php.litespeed
+%endif
+
+%if %{with cgi}
+%files cgi
+%defattr(644,root,root,755)
+%dir %{_sysconfdir}/cgi-fcgi.d
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php-cgi-fcgi.ini
+%attr(755,root,root) %{_bindir}/php.cgi
+%attr(755,root,root) %{_bindir}/php.fcgi
+%endif
+
+%files cli
+%defattr(644,root,root,755)
+%dir %{_sysconfdir}/cli.d
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php-cli.ini
+%attr(755,root,root) %{_bindir}/php.cli
+%{_mandir}/man1/php.1*
+%{_mandir}/man1/php.cli.1*
+
+%files program
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/php
+
+%if %{with fpm}
+%files fpm
+%defattr(644,root,root,755)
+%doc sapi/fpm/CREDITS
+%doc sapi/fpm/LICENSE
+%dir %{_sysconfdir}/fpm.d
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php-fpm.conf
+%attr(755,root,root) %{_sbindir}/php-fpm
+%{_mandir}/man8/php-fpm.8*
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/php-fpm
+%attr(754,root,root) /etc/rc.d/init.d/php-fpm
+%endif
+
+%files common
+%defattr(644,root,root,755)
+%doc php.ini-*
+%doc CREDITS Zend/ZEND_CHANGES
+%doc LICENSE Zend/LICENSE.Zend EXTENSIONS NEWS TODO*
+%doc README.PHP4-TO-PHP5-THIN-CHANGES
+%doc README.namespaces
+
+%dir %{_sysconfdir}
+%dir %{_sysconfdir}/conf.d
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php.ini
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/browscap.ini
+%attr(755,root,root) %{_libdir}/libphp_common-*.so
+%dir %{php_extensiondir}
+
+%doc ext/session/mod_files.sh
+
+%files devel
+%defattr(644,root,root,755)
+%doc README.UNIX-BUILD-SYSTEM
+%doc README.EXT_SKEL README.SELF-CONTAINED-EXTENSIONS
+%doc CODING_STANDARDS README.EXTENSIONS README.PARAMETER_PARSING_API README.STREAMS
+%doc README.SUBMITTING_PATCH README.TESTING README.TESTING2
+%attr(755,root,root) %{_bindir}/phpize
+%attr(755,root,root) %{_bindir}/php-config
+%attr(755,root,root) %{_libdir}/libphp_common.so
+%{_libdir}/libphp_common.la
+%{_includedir}/php
+%{_libdir}/php/build
+%{_mandir}/man1/php-config.1*
+%{_mandir}/man1/phpize.1*
+
+%files bcmath
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/bcmath.ini
+%attr(755,root,root) %{php_extensiondir}/bcmath.so
+
+%files bz2
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/bz2.ini
+%attr(755,root,root) %{php_extensiondir}/bz2.so
+
+%files calendar
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/calendar.ini
+%attr(755,root,root) %{php_extensiondir}/calendar.so
+
+%files ctype
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/ctype.ini
+%attr(755,root,root) %{php_extensiondir}/ctype.so
+
+%if %{with curl}
+%files curl
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/curl.ini
+%attr(755,root,root) %{php_extensiondir}/curl.so
+%endif
+
+%files dba
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/dba.ini
+%attr(755,root,root) %{php_extensiondir}/dba.so
+
+%files dom
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/dom.ini
+%attr(755,root,root) %{php_extensiondir}/dom.so
+
+%files exif
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/exif.ini
+%attr(755,root,root) %{php_extensiondir}/exif.so
+
+%files fileinfo
+%defattr(644,root,root,755)
+%doc README.input_filter
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/fileinfo.ini
+%attr(755,root,root) %{php_extensiondir}/fileinfo.so
+
+%if %{with filter}
+%files filter
+%defattr(644,root,root,755)
+%doc README.input_filter
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/filter.ini
+%attr(755,root,root) %{php_extensiondir}/filter.so
+%endif
+
+%files ftp
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/ftp.ini
+%attr(755,root,root) %{php_extensiondir}/ftp.so
+
+%files gd
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/gd.ini
+%attr(755,root,root) %{php_extensiondir}/gd.so
+
+%files gettext
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/gettext.ini
+%attr(755,root,root) %{php_extensiondir}/gettext.so
+
+%files gmp
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/gmp.ini
+%attr(755,root,root) %{php_extensiondir}/gmp.so
+
+%files hash
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/hash.ini
+%attr(755,root,root) %{php_extensiondir}/hash.so
+
+%files iconv
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/iconv.ini
+%attr(755,root,root) %{php_extensiondir}/iconv.so
+
+%if %{with imap}
+%files imap
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/imap.ini
+%attr(755,root,root) %{php_extensiondir}/imap.so
+%endif
+
+%if %{with interbase}
+%files interbase
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/interbase.ini
+%attr(755,root,root) %{php_extensiondir}/interbase.so
+%endif
+
+%files intl
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/intl.ini
+%attr(755,root,root) %{php_extensiondir}/intl.so
+
+%files json
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/json.ini
+%attr(755,root,root) %{php_extensiondir}/json.so
+
+%if %{with ldap}
+%files ldap
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/ldap.ini
+%attr(755,root,root) %{php_extensiondir}/ldap.so
+%endif
+
+%files mbstring
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/mbstring.ini
+%attr(755,root,root) %{php_extensiondir}/mbstring.so
+
+%files mcrypt
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/mcrypt.ini
+%attr(755,root,root) %{php_extensiondir}/mcrypt.so
+
+%if %{with mssql}
+%files mssql
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/mssql.ini
+%attr(755,root,root) %{php_extensiondir}/mssql.so
+%endif
+
+%files mysql
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/mysql.ini
+%attr(755,root,root) %{php_extensiondir}/mysql.so
+
+%if %{with mysqli}
+%files mysqli
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/mysqli.ini
+%attr(755,root,root) %{php_extensiondir}/mysqli.so
+%endif
+
+%if %{with mysqlnd}
+%files mysqlnd
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/MySQLND.ini
+%attr(755,root,root) %{php_extensiondir}/mysqlnd.so
+%endif
+
+%if %{with oci8}
+%files oci8
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/oci8.ini
+%attr(755,root,root) %{php_extensiondir}/oci8.so
+%endif
+
+%if %{with odbc}
+%files odbc
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/odbc.ini
+%attr(755,root,root) %{php_extensiondir}/odbc.so
+%endif
+
+%if %{with openssl}
+%files openssl
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/openssl.ini
+%attr(755,root,root) %{php_extensiondir}/openssl.so
+%endif
+
+%files pcntl
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pcntl.ini
+%attr(755,root,root) %{php_extensiondir}/pcntl.so
+
+%if %{with pcre}
+%files pcre
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/PCRE.ini
+%attr(755,root,root) %{php_extensiondir}/pcre.so
+%endif
+
+%files pdo
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo.ini
+%attr(755,root,root) %{php_extensiondir}/pdo.so
+
+%if %{with mssql} || %{with sybase_ct}
+%files pdo-dblib
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_dblib.ini
+%attr(755,root,root) %{php_extensiondir}/pdo_dblib.so
+%endif
+
+%if %{with interbase} && !%{with interbase_inst}
+%files pdo-firebird
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_firebird.ini
+%attr(755,root,root) %{php_extensiondir}/pdo_firebird.so
+%endif
+
+%files pdo-mysql
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_mysql.ini
+%attr(755,root,root) %{php_extensiondir}/pdo_mysql.so
+
+%if %{with oci8}
+%files pdo-oci
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_oci.ini
+%attr(755,root,root) %{php_extensiondir}/pdo_oci.so
+%endif
+
+%if %{with odbc}
+%files pdo-odbc
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_odbc.ini
+%attr(755,root,root) %{php_extensiondir}/pdo_odbc.so
+%endif
+
+%if %{with pgsql}
+%files pdo-pgsql
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_pgsql.ini
+%attr(755,root,root) %{php_extensiondir}/pdo_pgsql.so
+%endif
+
+%if %{with pdo_sqlite}
+%files pdo-sqlite
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_sqlite.ini
+%attr(755,root,root) %{php_extensiondir}/pdo_sqlite.so
+%endif
+
+%if %{with pgsql}
+%files pgsql
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pgsql.ini
+%attr(755,root,root) %{php_extensiondir}/pgsql.so
+%endif
+
+%if %{with phar}
+%files phar
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/phar.ini
+%attr(755,root,root) %{php_extensiondir}/phar.so
+%attr(755,root,root) %{_bindir}/phar
+%attr(755,root,root) %{_bindir}/phar.phar
+%endif
+
+%files posix
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/posix.ini
+%attr(755,root,root) %{php_extensiondir}/posix.so
+
+%if %{with pspell}
+%files pspell
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pspell.ini
+%attr(755,root,root) %{php_extensiondir}/pspell.so
+%endif
+
+%files readline
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/cli.d/readline.ini
+%attr(755,root,root) %{php_extensiondir}/readline.so
+
+%if %{with recode}
+%files recode
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/recode.ini
+%attr(755,root,root) %{php_extensiondir}/recode.so
+%endif
+
+%files session
+%defattr(644,root,root,755)
+%doc ext/session/mod_files.sh
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/Session.ini
+%attr(755,root,root) %{php_extensiondir}/session.so
+
+%files shmop
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/shmop.ini
+%attr(755,root,root) %{php_extensiondir}/shmop.so
+
+%files simplexml
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/simplexml.ini
+%attr(755,root,root) %{php_extensiondir}/simplexml.so
+
+%if %{with snmp}
+%files snmp
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/snmp.ini
+%attr(755,root,root) %{php_extensiondir}/snmp.so
+%endif
+
+%files soap
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/soap.ini
+%attr(755,root,root) %{php_extensiondir}/soap.so
+
+%files sockets
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/sockets.ini
+%attr(755,root,root) %{php_extensiondir}/sockets.so
+
+%files spl
+%defattr(644,root,root,755)
+%doc ext/spl/{CREDITS,README,TODO}
+%doc ext/spl/examples
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/SPL.ini
+%attr(755,root,root) %{php_extensiondir}/spl.so
+
+%if %{with sqlite2}
+%files sqlite
+%defattr(644,root,root,755)
+%doc ext/sqlite/{README,TODO,CREDITS}
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/sqlite.ini
+%attr(755,root,root) %{php_extensiondir}/sqlite.so
+%endif
+
+%if %{with sqlite3}
+%files sqlite3
+%defattr(644,root,root,755)
+%doc ext/sqlite3/CREDITS
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/sqlite3.ini
+%attr(755,root,root) %{php_extensiondir}/sqlite3.so
+%endif
+
+%if %{with sybase_ct}
+%files sybase-ct
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/sybase_ct.ini
+%attr(755,root,root) %{php_extensiondir}/sybase_ct.so
+%endif
+
+%files sysvmsg
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/sysvmsg.ini
+%attr(755,root,root) %{php_extensiondir}/sysvmsg.so
+
+%files sysvsem
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/sysvsem.ini
+%attr(755,root,root) %{php_extensiondir}/sysvsem.so
+
+%files sysvshm
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/sysvshm.ini
+%attr(755,root,root) %{php_extensiondir}/sysvshm.so
+
+%files tests
+%defattr(644,root,root,755)
+%dir %{php_data_dir}/tests/php
+%{php_data_dir}/tests/php/basic
+%{php_data_dir}/tests/php/classes
+%{php_data_dir}/tests/php/func
+%{php_data_dir}/tests/php/lang
+%{php_data_dir}/tests/php/output
+%{php_data_dir}/tests/php/run-test
+%{php_data_dir}/tests/php/security
+%{php_data_dir}/tests/php/strings
+%{php_data_dir}/tests/php/quicktester.inc
+%attr(755,root,root) %{php_data_dir}/tests/php/run-tests.php
+
+%if %{with tidy}
+%files tidy
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/tidy.ini
+%attr(755,root,root) %{php_extensiondir}/tidy.so
+%endif
+
+%files tokenizer
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/tokenizer.ini
+%attr(755,root,root) %{php_extensiondir}/tokenizer.so
+
+%if %{with wddx}
+%files wddx
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/*wddx.ini
+%attr(755,root,root) %{php_extensiondir}/wddx.so
+%endif
+
+%files xml
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/xml.ini
+%attr(755,root,root) %{php_extensiondir}/xml.so
+
+%files xmlreader
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/xmlreader.ini
+%attr(755,root,root) %{php_extensiondir}/xmlreader.so
+
+%if %{with xmlrpc}
+%files xmlrpc
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/xmlrpc.ini
+%attr(755,root,root) %{php_extensiondir}/xmlrpc.so
+%endif
+
+%files xmlwriter
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/xmlwriter.ini
+%attr(755,root,root) %{php_extensiondir}/xmlwriter.so
+
+%files xsl
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/xsl.ini
+%attr(755,root,root) %{php_extensiondir}/xsl.so
+
+%files zip
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/zip.ini
+%attr(755,root,root) %{php_extensiondir}/zip.so
+
+%files zlib
+%defattr(644,root,root,755)
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/zlib.ini
+%attr(755,root,root) %{php_extensiondir}/zlib.so
--- /dev/null
+#!/bin/sh
+# easter_date()
+mv ext/calendar/tests/easter_date.phpt{,.skip}
+# unixtojd()
+mv ext/calendar/tests/unixtojd.phpt{,.skip}
+# curl_setopt() basic parameter test
+mv ext/curl/tests/curl_setopt_error.phpt{,.skip}
+# timezone_abbreviations_list() tests
+mv ext/date/tests/010.phpt{,.skip}
+# Test DateTime::modify() function : usage variation - Passing unexpected values to first argument $modify.
+mv ext/date/tests/DateTime_modify_variation1.phpt{,.skip}
+# Bug #48187 (DateTime::diff() corrupting microtime() result)
+mv ext/date/tests/bug48187.phpt{,.skip}
+# Bug #50475 (DateTime::setISODate followed by DateTime::setTime)
+mv ext/date/tests/bug50475.phpt{,.skip}
+# Bug #51819 (Case discrepancy in timezone names cause Uncaught exception and fatal error)
+mv ext/date/tests/bug51819.phpt{,.skip}
+# Bug #51994 (date_parse_from_format is parsing invalid date using 'yz' format)
+mv ext/date/tests/bug51994.phpt{,.skip}
+# Bug #52290 (setDate, setISODate, setTime works wrong when DateTime created from timestamp)
+mv ext/date/tests/bug52290.phpt{,.skip}
+# Test date_modify() function : usage variation - Passing unexpected values to second argument $format.
+mv ext/date/tests/date_modify_variation2.phpt{,.skip}
+# Test timezone_abbreviations_list() function : basic functionality
+mv ext/date/tests/timezone_abbreviations_list_basic1.phpt{,.skip}
+# Test 5: HTML Test
+mv ext/dom/tests/dom005.phpt{,.skip}
+# Bug #48555 (ImageFTBBox() differs from previous versions for texts with new lines)
+mv ext/gd/tests/bug48555.phpt{,.skip}
+# Feature Request #50283 (allow base in gmp_strval to use full range: 2 to 62, and -2 to -36)
+mv ext/gmp/tests/bug50283.phpt{,.skip}
+# gmp_nextprime()
+mv ext/gmp/tests/gmp_nextprime.phpt{,.skip}
+# InterBase: connect, close and pconnect
+mv ext/interbase/tests/002.phpt{,.skip}
+# InterBase: misc sql types (may take a while)
+mv ext/interbase/tests/003.phpt{,.skip}
+# InterBase: BLOB test
+mv ext/interbase/tests/004.phpt{,.skip}
+# InterBase: transactions
+mv ext/interbase/tests/005.phpt{,.skip}
+# InterBase: binding (may take a while)
+mv ext/interbase/tests/006.phpt{,.skip}
+# InterBase: array handling
+mv ext/interbase/tests/007.phpt{,.skip}
+# InterBase: event handling
+mv ext/interbase/tests/008.phpt{,.skip}
+# Bug #45373 (php crash on query with errors in params)
+mv ext/interbase/tests/bug45373.phpt{,.skip}
+# Bug #45575 (Segfault with invalid non-string as event handler callback)
+mv ext/interbase/tests/bug45575.phpt{,.skip}
+# Bug #46247 (ibase_set_event_handler() is allowing to pass callback without event)
+mv ext/interbase/tests/bug46247.phpt{,.skip}
+# Bug #46543 (ibase_trans() memory leaks when using wrong parameters)
+mv ext/interbase/tests/bug46543.phpt{,.skip}
+# ibase_affected_rows(): Basic test
+mv ext/interbase/tests/ibase_affected_rows_001.phpt{,.skip}
+# ibase_close(): Basic test
+mv ext/interbase/tests/ibase_close_001.phpt{,.skip}
+# ibase_drop_db(): Basic test
+mv ext/interbase/tests/ibase_drop_db_001.phpt{,.skip}
+# ibase_errmsg(): Basic test
+mv ext/interbase/tests/ibase_errmsg_001.phpt{,.skip}
+# ibase_free_query(): Basic test
+mv ext/interbase/tests/ibase_free_query_001.phpt{,.skip}
+# ibase_num_fields(): Basic test
+mv ext/interbase/tests/ibase_num_fields_001.phpt{,.skip}
+# ibase_num_params(): Basic test
+mv ext/interbase/tests/ibase_num_params_001.phpt{,.skip}
+# ibase_param_info(): Basic test
+mv ext/interbase/tests/ibase_param_info_001.phpt{,.skip}
+# ibase_rollback(): Basic test
+mv ext/interbase/tests/ibase_rollback_001.phpt{,.skip}
+# ibase_trans(): Basic test
+mv ext/interbase/tests/ibase_trans_001.phpt{,.skip}
+# ibase_trans(): Basic operations
+mv ext/interbase/tests/ibase_trans_002.phpt{,.skip}
+# get_locale()
+mv ext/intl/tests/collator_get_locale.phpt{,.skip}
+# collator_get_sort_key()
+mv ext/intl/tests/collator_get_sort_key.phpt{,.skip}
+# datefmt_format_code() and datefmt_parse_code()
+mv ext/intl/tests/dateformat_format_parse.phpt{,.skip}
+# datefmt_get_pattern_code and datefmt_set_pattern_code()
+mv ext/intl/tests/dateformat_get_set_pattern.phpt{,.skip}
+# datefmt_localtime_code()
+mv ext/intl/tests/dateformat_localtime.phpt{,.skip}
+# datefmt_parse_code()
+mv ext/intl/tests/dateformat_parse.phpt{,.skip}
+# datefmt_parse_localtime() with parse pos
+mv ext/intl/tests/dateformat_parse_localtime_parsepos.phpt{,.skip}
+# datefmt_parse_timestamp_code() with parse pos
+mv ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt{,.skip}
+# datefmt_set_timezone_id_code()
+mv ext/intl/tests/dateformat_set_timezone_id.phpt{,.skip}
+# numfmt_format()
+mv ext/intl/tests/formatter_format.phpt{,.skip}
+# numfmt_format_currency()
+mv ext/intl/tests/formatter_format_currency.phpt{,.skip}
+# numfmt_get/set_attribute()
+mv ext/intl/tests/formatter_get_set_attribute.phpt{,.skip}
+# grapheme()
+mv ext/intl/tests/grapheme.phpt{,.skip}
+# locale_get_display_name()
+mv ext/intl/tests/locale_get_display_name.phpt{,.skip}
+# locale_get_display_script()
+mv ext/intl/tests/locale_get_display_script.phpt{,.skip}
+# locale_get_display_variant()
+mv ext/intl/tests/locale_get_display_variant.phpt{,.skip}
+# ldap_sasl_bind() - Basic anonymous binding
+mv ext/ldap/tests/ldap_sasl_bind_basic.phpt{,.skip}
+# mysql connect
+mv ext/mysql/tests/001.phpt{,.skip}
+# mysql_connect()
+mv ext/mysql/tests/mysql_connect.phpt{,.skip}
+# mysql_[p]connect() - max_links/max_persistent
+mv ext/mysql/tests/mysql_max_links.phpt{,.skip}
+# mysql_[p]connect() - safe_mode
+mv ext/mysql/tests/mysql_sql_safe_mode.phpt{,.skip}
+# mysqli_connect()
+mv ext/mysqli/tests/mysqli_connect.phpt{,.skip}
+# new mysqli()
+mv ext/mysqli/tests/mysqli_connect_oo.phpt{,.skip}
+# new mysqli()
+mv ext/mysqli/tests/mysqli_connect_oo_defaults.phpt{,.skip}
+# Bug #28382 (openssl_x509_parse extensions support)
+mv ext/openssl/tests/bug28382.phpt{,.skip}
+# Bug #47828 (segfaults when a UTF-8 conversion fails openssl_x509_parse())
+mv ext/openssl/tests/bug47828.phpt{,.skip}
+# openssl_x509_parse() basic test
+mv ext/openssl/tests/openssl_x509_parse_basic.phpt{,.skip}
+# PDO_Firebird: connect/disconnect
+mv ext/pdo_firebird/tests/connect.phpt{,.skip}
+# PDO_Firebird: DDL/transactions
+mv ext/pdo_firebird/tests/ddl.phpt{,.skip}
+# PDO_Firebird: prepare/execute/binding
+mv ext/pdo_firebird/tests/execute.phpt{,.skip}
+# MySQL PDO->__construct(), options
+mv ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt{,.skip}
+# MySQL PDO->__construct(), libmysql only options
+mv ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt{,.skip}
+# MySQL PDO class interface
+mv ext/pdo_mysql/tests/pdo_mysql_interface.phpt{,.skip}
+# PDO ODBC "long" columns
+mv ext/pdo_odbc/tests/long_columns.phpt{,.skip}
+# PDO SQLite Feature Request #42589 (getColumnMeta() should also return table name)
+mv ext/pdo_sqlite/tests/bug_42589.phpt{,.skip}
+# Test for bug 52013 about Phar::decompressFiles().
+mv ext/phar/tests/bug52013.phpt{,.skip}
+# Phar and RecursiveDirectoryIterator
+mv ext/phar/tests/phar_oo_005.phpt{,.skip}
+# Test posix_getgrgid() function : basic functionality
+mv ext/posix/tests/posix_getgrgid_basic.phpt{,.skip}
+# ReflectionClass::getConstructor()
+mv ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt{,.skip}
+# ReflectionMethod::isConstructor()
+mv ext/reflection/tests/ReflectionMethod_constructor_basic.phpt{,.skip}
+# ReflectionObject::getConstructor() - basic function test
+mv ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt{,.skip}
+# a script should not be able to modify session.use_trans_sid
+mv ext/session/tests/014.phpt{,.skip}
+# use_trans_sid should not affect SID
+mv ext/session/tests/015.phpt{,.skip}
+# rewriter correctly handles attribute names which contain dashes
+mv ext/session/tests/018.phpt{,.skip}
+# rewriter uses arg_seperator.output for modifying URLs
+mv ext/session/tests/020.phpt{,.skip}
+# rewriter handles form and fieldset tags correctly
+mv ext/session/tests/021.phpt{,.skip}
+# Bug #31454 (Incorrect adding PHPSESSID to links, which contains \r\n)
+mv ext/session/tests/bug36459.phpt{,.skip}
+# Bug #41600 (url rewriter tags doesn't work with namespaced tags)
+mv ext/session/tests/bug41600.phpt{,.skip}
+# Test session_encode() function : error functionality
+mv ext/session/tests/session_encode_error2.phpt{,.skip}
+# SimpleXML: XPath
+mv ext/simplexml/tests/008.phpt{,.skip}
+# SOAP Server 9: setclass and setpersistence(SOAP_PERSISTENCE_SESSION)
+mv ext/soap/tests/server009.phpt{,.skip}
+# ext/sockets - socket_strerror - basic test
+mv ext/sockets/tests/socket_strerror.phpt{,.skip}
+# Bug #38759 (sqlite2 empty query causes segfault)
+mv ext/sqlite/tests/bug38759.phpt{,.skip}
+# sqlite, session storage test
+mv ext/sqlite/tests/sqlite_session_001.phpt{,.skip}
+# sqlite, session destroy test
+mv ext/sqlite/tests/sqlite_session_002.phpt{,.skip}
+# SQLite3::loadExtension with empty extension test
+mv ext/sqlite3/tests/sqlite3_33_load_extension_param.phpt{,.skip}
+# SQLite3::loadExtension with disabled extensions
+mv ext/sqlite3/tests/sqlite3_34_load_extension_ext_dir.phpt{,.skip}
+# SQLite3::loadExtension test with wrong parameter type
+mv ext/sqlite3/tests/sqlite3_loadextension_with_wrong_param.phpt{,.skip}
+# Test fscanf() function: usage variations - unsigned int formats with integer values
+mv ext/standard/tests/file/fscanf_variation39.phpt{,.skip}
+# Test fscanf() function: usage variations - tracking file pointer while reading
+mv ext/standard/tests/file/fscanf_variation55.phpt{,.skip}
+# Bug #44394 (Last two bytes missing from output) with session.use_trans_id
+mv ext/standard/tests/general_functions/bug44394_2.phpt{,.skip}
+# Test function getservbyname()
+mv ext/standard/tests/general_functions/getservbyname_basic.phpt{,.skip}
+# proc_open
+mv ext/standard/tests/general_functions/proc_open02.phpt{,.skip}
+# time_sleep_until() function - basic test for time_sleep_until()
+mv ext/standard/tests/misc/time_sleep_until_basic.phpt{,.skip}
+# htmlentities() test 2 (setlocale / fr_FR.ISO-8859-15)
+mv ext/standard/tests/strings/htmlentities02.phpt{,.skip}
+# htmlentities() test 4 (setlocale / ja_JP.EUC-JP)
+mv ext/standard/tests/strings/htmlentities04.phpt{,.skip}
+# htmlentities() test 10 (default_charset / cp1252)
+mv ext/standard/tests/strings/htmlentities10.phpt{,.skip}
+# htmlentities() test 11 (default_charset / ISO-8859-15)
+mv ext/standard/tests/strings/htmlentities11.phpt{,.skip}
+# htmlentities() test 13 (default_charset / EUC-JP)
+mv ext/standard/tests/strings/htmlentities13.phpt{,.skip}
+# htmlentities() test 15 (setlocale / KOI8-R)
+mv ext/standard/tests/strings/htmlentities15.phpt{,.skip}
+# htmlentities() / html_entity_decode() #8592 - #9002 table test
+mv ext/standard/tests/strings/htmlentities17.phpt{,.skip}
+# Test setlocale() function : usage variations - Setting all available locales in the platform
+mv ext/standard/tests/strings/setlocale_variation2.phpt{,.skip}
+# Test sscanf() function : basic functionality - unsigned format
+mv ext/standard/tests/strings/sscanf_basic6.phpt{,.skip}
+# msg_send() data types when not serializing
+mv ext/sysvmsg/tests/006.phpt{,.skip}
+# wddx session serializer handler (serialize)
+mv ext/wddx/tests/004.phpt{,.skip}
+# wddx session serializer handler (deserialize)
+mv ext/wddx/tests/005.phpt{,.skip}
+# xmlrpc_encode_request() and various arguments
+mv ext/xmlrpc/tests/002.phpt{,.skip}
+# Bug #40576 (double values are truncated to 6 decimal digits when encoding)
+mv ext/xmlrpc/tests/bug40576_64bit.phpt{,.skip}
+# Bug #45555 (Segfault with invalid non-string as register_introspection_callback)
+mv ext/xmlrpc/tests/bug45555.phpt{,.skip}
+# Bug #45556 (Return value from callback isn't freed)
+mv ext/xmlrpc/tests/bug45556.phpt{,.skip}
+# Test 10: EXSLT Support
+mv ext/xsl/tests/xslt010.phpt{,.skip}
+# Check xsltprocessor::registerPHPFunctions and a non-string function in xsl
+mv ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcnostring.phpt{,.skip}
+# Check xsltprocessor::registerPHPFunctions and a undefined php function
+mv ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcundef.phpt{,.skip}
+# show information about extension
+mv sapi/cli/tests/006.phpt{,.skip}
+# CLI -a and readline
+mv sapi/cli/tests/016.phpt{,.skip}
+# Phar::buildFromIterator() RegexIterator(RecursiveIteratorIterator), SplFileInfo as current
+mv ext/phar/tests/phar_buildfromiterator10.phpt{,.skip}
+# output buffering - fatalism
+mv tests/output/ob_011.phpt{,.skip}
+# Inconsistencies when accessing protected members
+mv Zend/tests/access_modifiers_008.phpt{,.skip}
+# Inconsistencies when accessing protected members - 2
+mv Zend/tests/access_modifiers_009.phpt{,.skip}
+# Bug #48770 (call_user_func_array() fails to call parent from inheriting class)
+mv Zend/tests/bug48770.phpt{,.skip}
+# Bug #48770 (call_user_func_array() fails to call parent from inheriting class)
+mv Zend/tests/bug48770_2.phpt{,.skip}
+# Bug #48770 (call_user_func_array() fails to call parent from inheriting class)
+mv Zend/tests/bug48770_3.phpt{,.skip}
+# DBA with persistent connections
+mv ext/dba/tests/dba015.phpt{,.skip}
+# DBA DB4 with persistent connections
+mv ext/dba/tests/dba_db4_018.phpt{,.skip}
+# Bug #42718 (unsafe_raw filter not applied when configured as default filter)
+mv ext/filter/tests/bug42718.phpt{,.skip}
+# SimpleXML: array casting bug
+mv ext/simplexml/tests/034.phpt{,.skip}
+# Bug #39863 (file_exists() silently truncates after a null byte)
+mv ext/standard/tests/file/bug39863.phpt{,.skip}
+# DOMDocument::$validateOnParse - effectual determination (dom_document_validate_on_parse_read/dom_document_validate_on_parse_write)
+mv ext/dom/tests/DOMDocument_validate_on_parse_variation.phpt{,.skip}
+# Bug #40576 (double values are truncated to 6 decimal digits when encoding)
+mv ext/xmlrpc/tests/bug40576.phpt{,.skip}
--- /dev/null
+--- php-5.3.1/ext/spl/config.m4~ 2009-11-26 23:54:34.000000000 +0000
++++ php-5.3.1/ext/spl/config.m4 2009-11-27 08:04:05.788823797 +0000
+@@ -22,6 +22,6 @@
+ CPPFLAGS=$old_CPPFLAGS
+ AC_DEFINE_UNQUOTED(HAVE_PACKED_OBJECT_VALUE, $ac_result, [Whether struct _zend_object_value is packed])
+ AC_DEFINE(HAVE_SPL, 1, [Whether you want SPL (Standard PHP Library) support])
+- PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no)
++ PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, $ext_shared)
+ PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h])
+ PHP_ADD_EXTENSION_DEP(spl, pcre, true)
+--- php-5.3.1/ext/spl/spl_iterators.c~ 2009-07-04 20:31:27.000000000 +0000
++++ php-5.3.1/ext/spl/spl_iterators.c 2009-11-27 16:35:33.729087793 +0000
+@@ -58,7 +58,13 @@
+ PHPAPI zend_class_entry *spl_ce_AppendIterator;
+ PHPAPI zend_class_entry *spl_ce_RegexIterator;
+ PHPAPI zend_class_entry *spl_ce_RecursiveRegexIterator;
++#if COMPILE_DL_SPL
++#undef spl_ce_Countable
++zend_class_entry *spl_ce_Countable; // real instance
++extern PHPAPI zend_class_entry *spl_ce_Countable_p; // external one
++#else
+ PHPAPI zend_class_entry *spl_ce_Countable;
++#endif
+ PHPAPI zend_class_entry *spl_ce_RecursiveTreeIterator;
+
+ ZEND_BEGIN_ARG_INFO(arginfo_recursive_it_void, 0)
+@@ -3286,6 +3292,10 @@
+ REGISTER_SPL_STD_CLASS_EX(EmptyIterator, NULL, spl_funcs_EmptyIterator);
+ REGISTER_SPL_ITERATOR(EmptyIterator);
+
++#if COMPILE_DL_SPL
++ spl_ce_Countable_p = spl_ce_Countable;
++#endif
++
+ REGISTER_SPL_SUB_CLASS_EX(RecursiveTreeIterator, RecursiveIteratorIterator, spl_RecursiveTreeIterator_new, spl_funcs_RecursiveTreeIterator);
+ REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "BYPASS_CURRENT", RTIT_BYPASS_CURRENT);
+ REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "BYPASS_KEY", RTIT_BYPASS_KEY);
+--- php-5.3.1/ext/spl/spl_iterators.h~ 2008-12-31 11:15:49.000000000 +0000
++++ php-5.3.1/ext/spl/spl_iterators.h 2009-11-27 16:36:35.215748808 +0000
+@@ -51,7 +51,12 @@
+ extern PHPAPI zend_class_entry *spl_ce_AppendIterator;
+ extern PHPAPI zend_class_entry *spl_ce_RegexIterator;
+ extern PHPAPI zend_class_entry *spl_ce_RecursiveRegexIterator;
++#if COMPILE_DL_SPL
++#define spl_ce_Countable spl_ce_Countable_p
++extern PHPAPI zend_class_entry *spl_ce_Countable_p;
++#else
+ extern PHPAPI zend_class_entry *spl_ce_Countable;
++#endif
+
+ PHP_MINIT_FUNCTION(spl_iterators);
+
+--- php-5.3.1/ext/standard/array.c~ 2009-08-14 06:20:21.000000000 +0000
++++ php-5.3.1/ext/standard/array.c 2009-11-27 16:37:15.029078323 +0000
+@@ -49,6 +49,9 @@
+ #ifdef HAVE_SPL
+ #include "ext/spl/spl_array.h"
+ #endif
++#if COMPILE_DL_SPL
++PHPAPI zend_class_entry *spl_ce_Countable_p = NULL; // external one
++#endif
+
+ /* {{{ defines */
+ #define EXTR_OVERWRITE 0
+--- php-5.3.1/ext/pdo/pdo.c~ 2009-07-19 22:46:03.000000000 +0000
++++ php-5.3.1/ext/pdo/pdo.c 2009-11-27 16:37:51.332409104 +0000
+@@ -132,7 +132,7 @@
+ /* {{{ pdo_functions[] */
+ #if ZEND_MODULE_API_NO >= 20050922
+ static const zend_module_dep pdo_deps[] = {
+-#ifdef HAVE_SPL
++#ifdef HAVE_SPL && !COMPILE_DL_SPL
+ ZEND_MOD_REQUIRED("spl")
+ #endif
+ {NULL, NULL, NULL}
+--- php-5.3.1/ext/phar/Makefile.frag~ 2009-07-23 15:48:04.000000000 +0000
++++ php-5.3.1/ext/phar/Makefile.frag 2009-11-30 16:10:29.687175948 +0000
+@@ -10,7 +10,7 @@
+ $(top_srcdir)/build/shtool echo -n -- "$(top_builddir)/$(SAPI_CLI_PATH) -n"; \
+ if test "x$(PHP_MODULES)" != "x"; then \
+ $(top_srcdir)/build/shtool echo -n -- " -d extension_dir=$(top_builddir)/modules"; \
+- for i in bz2 zlib phar; do \
++ for i in pcre spl bz2 zlib phar; do \
+ if test -f "$(top_builddir)/modules/$$i.la"; then \
+ . $(top_builddir)/modules/$$i.la; $(top_srcdir)/build/shtool echo -n -- " -d extension=$$dlname"; \
+ fi; \
--- /dev/null
+diff -Naurp php-5.3.6RC1/configure php-5.3.6RC1.oden/configure
+--- php-5.3.6RC1/configure 2011-02-16 21:30:40.000000000 +0100
++++ php-5.3.6RC1.oden/configure 2011-02-20 11:50:19.294835319 +0100
+@@ -18979,6 +18979,9 @@ EOF
+
+ fi
+
++cat >> confdefs.h <<\EOF
++#define SUHOSIN_PATCH 1
++EOF
+
+ echo $ac_n "checking for declared timezone""... $ac_c" 1>&6
+ echo "configure:18985: checking for declared timezone" >&5
+@@ -115340,7 +115343,7 @@ EOF
+ php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
+ strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c \
+ network.c php_open_temporary_file.c php_logos.c \
+- output.c getopt.c; do
++ output.c getopt.c suhosin_patch.c ; do
+
+ IFS=.
+ set $ac_src
+@@ -115544,7 +115547,7 @@ esac
+ zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \
+ zend_ini.c zend_qsort.c zend_multibyte.c zend_ts_hash.c zend_stream.c \
+ zend_iterators.c zend_interfaces.c zend_exceptions.c zend_strtod.c zend_gc.c \
+- zend_closures.c zend_float.c; do
++ zend_closures.c zend_float.c zend_canary.c zend_alloc_canary.c ; do
+
+ IFS=.
+ set $ac_src
+diff -Naurp php-5.3.6RC1/configure.in php-5.3.6RC1.oden/configure.in
+--- php-5.3.6RC1/configure.in 2011-02-20 11:45:04.157489906 +0100
++++ php-5.3.6RC1.oden/configure.in 2011-02-20 11:50:19.295835459 +0100
+@@ -286,6 +286,7 @@ sinclude(Zend/Zend.m4)
+ sinclude(TSRM/threads.m4)
+ sinclude(TSRM/tsrm.m4)
+
++sinclude(main/suhosin_patch.m4)
+
+ divert(2)
+
+@@ -1393,7 +1394,7 @@ PHP_ADD_SOURCES(main, main.c snprintf.c
+ php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
+ strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c \
+ network.c php_open_temporary_file.c php_logos.c \
+- output.c getopt.c)
++ output.c getopt.c suhosin_patch.c )
+
+ PHP_ADD_SOURCES(main/streams, streams.c cast.c memory.c filter.c \
+ plain_wrapper.c userspace.c transports.c xp_socket.c mmap.c \
+@@ -1421,7 +1422,7 @@ PHP_ADD_SOURCES(Zend, \
+ zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \
+ zend_ini.c zend_qsort.c zend_multibyte.c zend_ts_hash.c zend_stream.c \
+ zend_iterators.c zend_interfaces.c zend_exceptions.c zend_strtod.c zend_gc.c \
+- zend_closures.c zend_float.c)
++ zend_closures.c zend_float.c zend_canary.c zend_alloc_canary.c )
+
+ if test -r "$abs_srcdir/Zend/zend_objects.c"; then
+ PHP_ADD_SOURCES(Zend, zend_objects.c zend_object_handlers.c zend_objects_API.c zend_default_classes.c)
+diff -Naurp php-5.3.6RC1/ext/standard/dl.c php-5.3.6RC1.oden/ext/standard/dl.c
+--- php-5.3.6RC1/ext/standard/dl.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/ext/standard/dl.c 2011-02-20 11:50:19.296835599 +0100
+@@ -254,6 +254,23 @@ PHPAPI int php_load_extension(char *file
+ return FAILURE;
+ }
+ }
++
++#if SUHOSIN_PATCH
++ if (strncmp("suhosin", module_entry->name, sizeof("suhosin")-1) == 0) {
++ void *log_func;
++ /* sucessfully loaded suhosin extension, now check for logging function replacement */
++ log_func = (void *) DL_FETCH_SYMBOL(handle, "suhosin_log");
++ if (log_func == NULL) {
++ log_func = (void *) DL_FETCH_SYMBOL(handle, "_suhosin_log");
++ }
++ if (log_func != NULL) {
++ zend_suhosin_log = log_func;
++ } else {
++ zend_suhosin_log(S_MISC, "could not replace logging function");
++ }
++ }
++#endif
++
+ return SUCCESS;
+ }
+ /* }}} */
+diff -Naurp php-5.3.6RC1/ext/standard/info.c php-5.3.6RC1.oden/ext/standard/info.c
+--- php-5.3.6RC1/ext/standard/info.c 2011-02-20 11:45:04.155489624 +0100
++++ php-5.3.6RC1.oden/ext/standard/info.c 2011-02-20 11:50:19.297835740 +0100
+@@ -885,6 +885,33 @@ PHPAPI void php_print_info(int flag TSRM
+
+ php_info_print_table_end();
+
++ /* Suhosin Patch */
++ php_info_print_box_start(0);
++ if (expose_php && !sapi_module.phpinfo_as_text) {
++ PUTS("<a href=\"http://www.suhosin.org\"><img border=\"0\" src=\"");
++ if (SG(request_info).request_uri) {
++ char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
++ PUTS(elem_esc);
++ efree(elem_esc);
++ }
++ PUTS("?="SUHOSIN_LOGO_GUID"\" alt=\"Suhosin logo\" /></a>\n");
++ }
++ PUTS("This server is protected with the Suhosin Patch ");
++ if (sapi_module.phpinfo_as_text) {
++ PUTS(SUHOSIN_PATCH_VERSION);
++ } else {
++ zend_html_puts(SUHOSIN_PATCH_VERSION, strlen(SUHOSIN_PATCH_VERSION) TSRMLS_CC);
++ }
++ PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n");
++ if (sapi_module.phpinfo_as_text) {
++ PUTS("Copyright (c) 2006-2007 Hardened-PHP Project\n");
++ PUTS("Copyright (c) 2007-2009 SektionEins GmbH\n");
++ } else {
++ PUTS("Copyright (c) 2006-2007 <a href=\"http://www.hardened-php.net/\">Hardened-PHP Project</a>\n");
++ PUTS("Copyright (c) 2007-2009 <a href=\"http://www.sektioneins.de/\">SektionEins GmbH</a>\n");
++ }
++ php_info_print_box_end();
++
+ /* Zend Engine */
+ php_info_print_box_start(0);
+ if (expose_php && !sapi_module.phpinfo_as_text) {
+diff -Naurp php-5.3.6RC1/ext/standard/syslog.c php-5.3.6RC1.oden/ext/standard/syslog.c
+--- php-5.3.6RC1/ext/standard/syslog.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/ext/standard/syslog.c 2011-02-20 11:50:19.299836022 +0100
+@@ -42,6 +42,7 @@ static void start_syslog(TSRMLS_D);
+ */
+ PHP_MINIT_FUNCTION(syslog)
+ {
++#if !SUHOSIN_PATCH
+ /* error levels */
+ REGISTER_LONG_CONSTANT("LOG_EMERG", LOG_EMERG, CONST_CS | CONST_PERSISTENT); /* system unusable */
+ REGISTER_LONG_CONSTANT("LOG_ALERT", LOG_ALERT, CONST_CS | CONST_PERSISTENT); /* immediate action required */
+@@ -97,6 +98,7 @@ PHP_MINIT_FUNCTION(syslog)
+ /* AIX doesn't have LOG_PERROR */
+ REGISTER_LONG_CONSTANT("LOG_PERROR", LOG_PERROR, CONST_CS | CONST_PERSISTENT); /*log to stderr*/
+ #endif
++#endif
+ BG(syslog_device)=NULL;
+
+ return SUCCESS;
+diff -Naurp php-5.3.6RC1/main/fopen_wrappers.c php-5.3.6RC1.oden/main/fopen_wrappers.c
+--- php-5.3.6RC1/main/fopen_wrappers.c 2011-01-18 23:20:09.000000000 +0100
++++ php-5.3.6RC1.oden/main/fopen_wrappers.c 2011-02-20 11:50:19.299836022 +0100
+@@ -85,13 +85,8 @@ or a tightening during activation/runtim
+ PHPAPI ZEND_INI_MH(OnUpdateBaseDir)
+ {
+ char **p, *pathbuf, *ptr, *end;
+-#ifndef ZTS
+- char *base = (char *) mh_arg2;
+-#else
+- char *base = (char *) ts_resource(*((int *) mh_arg2));
+-#endif
+
+- p = (char **) (base + (size_t) mh_arg1);
++ p = &PG(open_basedir);
+
+ if (stage == PHP_INI_STAGE_STARTUP || stage == PHP_INI_STAGE_SHUTDOWN || stage == PHP_INI_STAGE_ACTIVATE || stage == PHP_INI_STAGE_DEACTIVATE) {
+ /* We're in a PHP_INI_SYSTEM context, no restrictions */
+diff -Naurp php-5.3.6RC1/main/main.c php-5.3.6RC1.oden/main/main.c
+--- php-5.3.6RC1/main/main.c 2011-02-08 22:40:51.000000000 +0100
++++ php-5.3.6RC1.oden/main/main.c 2011-02-20 11:50:19.301836304 +0100
+@@ -90,6 +90,9 @@
+
+ #include "SAPI.h"
+ #include "rfc1867.h"
++#if SUHOSIN_PATCH
++#include "suhosin_globals.h"
++#endif
+
+ #if HAVE_SYS_MMAN_H
+ # include <sys/mman.h>
+@@ -490,7 +493,7 @@ PHP_INI_BEGIN()
+ STD_PHP_INI_ENTRY("extension_dir", PHP_EXTENSION_DIR, PHP_INI_SYSTEM, OnUpdateStringUnempty, extension_dir, php_core_globals, core_globals)
+ STD_PHP_INI_ENTRY("include_path", PHP_INCLUDE_PATH, PHP_INI_ALL, OnUpdateStringUnempty, include_path, php_core_globals, core_globals)
+ PHP_INI_ENTRY("max_execution_time", "30", PHP_INI_ALL, OnUpdateTimeout)
+- STD_PHP_INI_ENTRY("open_basedir", NULL, PHP_INI_ALL, OnUpdateBaseDir, open_basedir, php_core_globals, core_globals)
++ PHP_INI_ENTRY("open_basedir", NULL, PHP_INI_ALL, OnUpdateBaseDir)
+ STD_PHP_INI_ENTRY("safe_mode_exec_dir", PHP_SAFE_MODE_EXEC_DIR, PHP_INI_SYSTEM, OnUpdateString, safe_mode_exec_dir, php_core_globals, core_globals)
+
+ STD_PHP_INI_BOOLEAN("file_uploads", "1", PHP_INI_SYSTEM, OnUpdateBool, file_uploads, php_core_globals, core_globals)
+@@ -1781,6 +1784,10 @@ void dummy_invalid_parameter_handler(
+ }
+ #endif
+
++#if SUHOSIN_PATCH
++PHPAPI void suhosin_startup();
++#endif
++
+ /* {{{ php_module_startup
+ */
+ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint num_additional_modules)
+@@ -1825,6 +1832,10 @@ int php_module_startup(sapi_module_struc
+ tsrm_ls = ts_resource(0);
+ #endif
+
++#if SUHOSIN_PATCH
++ suhosin_startup();
++#endif
++
+ module_shutdown = 0;
+ module_startup = 1;
+ sapi_initialize_empty_request(TSRMLS_C);
+@@ -1944,7 +1955,11 @@ int php_module_startup(sapi_module_struc
+ 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);
+ REGISTER_MAIN_STRINGL_CONSTANT("PHP_SHLIB_SUFFIX", PHP_SHLIB_SUFFIX, sizeof(PHP_SHLIB_SUFFIX)-1, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_STRINGL_CONSTANT("PHP_EOL", PHP_EOL, sizeof(PHP_EOL)-1, CONST_PERSISTENT | CONST_CS);
+- REGISTER_MAIN_LONG_CONSTANT("PHP_MAXPATHLEN", MAXPATHLEN, CONST_PERSISTENT | CONST_CS);
++#if SUHOSIN_PATCH
++ REGISTER_MAIN_LONG_CONSTANT("SUHOSIN_PATCH", 1, CONST_PERSISTENT | CONST_CS);
++ REGISTER_MAIN_STRINGL_CONSTANT("SUHOSIN_PATCH_VERSION", SUHOSIN_PATCH_VERSION, sizeof(SUHOSIN_PATCH_VERSION)-1, CONST_PERSISTENT | CONST_CS);
++#endif
++ REGISTER_MAIN_LONG_CONSTANT("PHP_MAXPATHLEN", MAXPATHLEN, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MAX", LONG_MAX, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", sizeof(long), CONST_PERSISTENT | CONST_CS);
+ #ifdef ZEND_MULTIBYTE
+diff -Naurp php-5.3.6RC1/main/php_config.h.in php-5.3.6RC1.oden/main/php_config.h.in
+--- php-5.3.6RC1/main/php_config.h.in 2011-02-16 21:30:44.000000000 +0100
++++ php-5.3.6RC1.oden/main/php_config.h.in 2011-02-20 11:50:19.302836444 +0100
+@@ -851,6 +851,9 @@
+ /* Define if the target system has /dev/urandom device */
+ #undef HAVE_DEV_URANDOM
+
++/* Suhosin-Patch for PHP */
++#undef SUHOSIN_PATCH
++
+ /* Whether you have AOLserver */
+ #undef HAVE_AOLSERVER
+
+diff -Naurp php-5.3.6RC1/main/php.h php-5.3.6RC1.oden/main/php.h
+--- php-5.3.6RC1/main/php.h 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/main/php.h 2011-02-20 11:50:19.303836584 +0100
+@@ -453,6 +453,10 @@ END_EXTERN_C()
+ #endif
+ #endif /* !XtOffsetOf */
+
++#if SUHOSIN_PATCH
++#include "suhosin_patch.h"
++#endif
++
+ #endif
+
+ /*
+diff -Naurp php-5.3.6RC1/main/php_logos.c php-5.3.6RC1.oden/main/php_logos.c
+--- php-5.3.6RC1/main/php_logos.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/main/php_logos.c 2011-02-20 11:50:19.303836584 +0100
+@@ -50,6 +50,10 @@ PHPAPI int php_unregister_info_logo(char
+ return zend_hash_del(&phpinfo_logo_hash, logo_string, strlen(logo_string));
+ }
+
++#if SUHOSIN_PATCH
++#include "suhosin_logo.h"
++#endif
++
+ int php_init_info_logos(void)
+ {
+ if(zend_hash_init(&phpinfo_logo_hash, 0, NULL, NULL, 1)==FAILURE)
+@@ -58,7 +62,9 @@ int php_init_info_logos(void)
+ php_register_info_logo(PHP_EGG_LOGO_GUID, "image/gif", php_egg_logo, sizeof(php_egg_logo));
+ php_register_info_logo(ZEND_LOGO_GUID , "image/gif", zend_logo , sizeof(zend_logo));
+ php_register_info_logo(PLD_LOGO_GUID , "image/png", pld_logo , sizeof(pld_logo));
+-
++#if SUHOSIN_PATCH
++ php_register_info_logo(SUHOSIN_LOGO_GUID, "image/jpeg", suhosin_logo , sizeof(suhosin_logo));
++#endif
+ return SUCCESS;
+ }
+
+diff -Naurp php-5.3.6RC1/main/snprintf.c php-5.3.6RC1.oden/main/snprintf.c
+--- php-5.3.6RC1/main/snprintf.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/main/snprintf.c 2011-02-20 11:50:19.304836724 +0100
+@@ -780,6 +780,10 @@ static int format_converter(register buf
+ */
+ switch (*fmt) {
+ case 'Z':
++#if SUHOSIN_PATCH
++ zend_suhosin_log(S_MISC, "'Z' specifier within format string");
++ goto skip_output;
++#else
+ zvp = (zval*) va_arg(ap, zval*);
+ zend_make_printable_zval(zvp, &zcopy, &free_zcopy);
+ if (free_zcopy) {
+@@ -790,6 +794,7 @@ static int format_converter(register buf
+ if (adjust_precision && precision < s_len) {
+ s_len = precision;
+ }
++#endif
+ break;
+ case 'u':
+ switch(modifier) {
+@@ -1091,7 +1096,11 @@ static int format_converter(register buf
+
+
+ case 'n':
++#if SUHOSIN_PATCH
++ zend_suhosin_log(S_MISC, "'n' specifier within format string");
++#else
+ *(va_arg(ap, int *)) = cc;
++#endif
+ goto skip_output;
+
+ /*
+diff -Naurp php-5.3.6RC1/main/spprintf.c php-5.3.6RC1.oden/main/spprintf.c
+--- php-5.3.6RC1/main/spprintf.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/main/spprintf.c 2011-02-20 11:50:19.305836865 +0100
+@@ -388,6 +388,10 @@ static void xbuf_format_converter(smart_
+ */
+ switch (*fmt) {
+ case 'Z':
++#if SUHOSIN_PATCH
++ zend_suhosin_log(S_MISC, "'Z' specifier within format string");
++ goto skip_output;
++#else
+ zvp = (zval*) va_arg(ap, zval*);
+ zend_make_printable_zval(zvp, &zcopy, &free_zcopy);
+ if (free_zcopy) {
+@@ -398,6 +402,7 @@ static void xbuf_format_converter(smart_
+ if (adjust_precision && precision < s_len) {
+ s_len = precision;
+ }
++#endif
+ break;
+ case 'u':
+ switch(modifier) {
+@@ -698,7 +703,11 @@ static void xbuf_format_converter(smart_
+
+
+ case 'n':
++#if SUHOSIN_PATCH
++ zend_suhosin_log(S_MISC, "'n' specifier within format string");
++#else
+ *(va_arg(ap, int *)) = xbuf->len;
++#endif
+ goto skip_output;
+
+ /*
+diff -Naurp php-5.3.6RC1/main/suhosin_globals.h php-5.3.6RC1.oden/main/suhosin_globals.h
+--- php-5.3.6RC1/main/suhosin_globals.h 1970-01-01 01:00:00.000000000 +0100
++++ php-5.3.6RC1.oden/main/suhosin_globals.h 2011-02-20 11:50:19.306837006 +0100
+@@ -0,0 +1,61 @@
++/*
++ +----------------------------------------------------------------------+
++ | Suhosin-Patch for PHP |
++ +----------------------------------------------------------------------+
++ | Copyright (c) 2004-2009 Stefan Esser |
++ +----------------------------------------------------------------------+
++ | This source file is subject to version 2.02 of the PHP license, |
++ | that is bundled with this package in the file LICENSE, and is |
++ | available at through the world-wide-web at |
++ | http://www.php.net/license/2_02.txt. |
++ | If you did not receive a copy of the PHP license and are unable to |
++ | obtain it through the world-wide-web, please send a note to |
++ | license@php.net so we can mail you a copy immediately. |
++ +----------------------------------------------------------------------+
++ | Author: Stefan Esser <stefan.esser@sektioneins.de> |
++ +----------------------------------------------------------------------+
++ */
++
++#ifndef SUHOSIN_GLOBALS_H
++#define SUHOSIN_GLOBALS_H
++
++typedef struct _suhosin_patch_globals suhosin_patch_globals_struct;
++
++#ifdef ZTS
++# define SPG(v) TSRMG(suhosin_patch_globals_id, suhosin_patch_globals_struct *, v)
++extern int suhosin_patch_globals_id;
++#else
++# define SPG(v) (suhosin_patch_globals.v)
++extern struct _suhosin_patch_globals suhosin_patch_globals;
++#endif
++
++
++struct _suhosin_patch_globals {
++ /* logging */
++ int log_syslog;
++ int log_syslog_facility;
++ int log_syslog_priority;
++ int log_sapi;
++ int log_script;
++ int log_phpscript;
++ char *log_scriptname;
++ char *log_phpscriptname;
++ zend_bool log_phpscript_is_safe;
++ zend_bool log_use_x_forwarded_for;
++
++ /* memory manager canary protection */
++ unsigned int canary_1;
++ unsigned int canary_2;
++ unsigned int canary_3;
++ unsigned int dummy;
++};
++
++
++#endif /* SUHOSIN_GLOBALS_H */
++
++/*
++ * Local variables:
++ * tab-width: 4
++ * c-basic-offset: 4
++ * End:
++ */
+diff -Naurp php-5.3.6RC1/main/suhosin_logo.h php-5.3.6RC1.oden/main/suhosin_logo.h
+--- php-5.3.6RC1/main/suhosin_logo.h 1970-01-01 01:00:00.000000000 +0100
++++ php-5.3.6RC1.oden/main/suhosin_logo.h 2011-02-20 11:50:19.306837006 +0100
+@@ -0,0 +1,178 @@
++static unsigned char suhosin_logo[] =
++ "\xff\xd8\xff\xe0\x00\x10\x4a\x46\x49\x46\x00\x01\x01\x01\x00\x48"
++ "\x00\x48\x00\x00\xff\xe1\x00\x16\x45\x78\x69\x66\x00\x00\x4d\x4d"
++ "\x00\x2a\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\xff\xdb\x00\x43"
++ "\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
++ "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
++ "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
++ "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
++ "\x01\xff\xc0\x00\x0b\x08\x00\x27\x00\x71\x01\x01\x22\x00\xff\xc4"
++ "\x00\x1e\x00\x00\x02\x02\x02\x03\x01\x01\x00\x00\x00\x00\x00\x00"
++ "\x00\x00\x00\x00\x09\x06\x08\x05\x07\x02\x03\x0a\x01\x04\xff\xc4"
++ "\x00\x32\x10\x00\x01\x04\x03\x00\x02\x00\x05\x01\x05\x09\x01\x00"
++ "\x00\x00\x00\x05\x02\x03\x04\x06\x01\x07\x08\x00\x09\x11\x12\x13"
++ "\x14\x21\x15\x0a\x16\x31\x56\x96\x17\x18\x19\x23\x32\x41\x58\x98"
++ "\xd4\xd6\xff\xda\x00\x08\x01\x01\x00\x00\x3f\x00\xf4\xc1\xe1\xe5"
++ "\x69\xe9\x3e\xb9\xd1\x7c\x8a\x2e\x9d\x66\xe8\x3b\x29\x4d\x7f\x46"
++ "\xba\x58\x55\x54\x8d\xb1\x5f\xaa\xd9\x8d\x51\x2b\xb6\x27\x5a\x69"
++ "\xd1\x43\xaf\x16\x1a\xf0\xb2\xb1\xe9\x6d\x9f\xc2\xa4\x36\x18\xb5"
++ "\x85\x10\x41\xbe\xfc\x09\xac\x49\x29\x11\xd4\x32\x97\xec\x08\x13"
++ "\xc1\x2d\x20\xc3\x59\xeb\x26\x05\xd8\x6b\x76\x31\x43\x8f\x57\xcf"
++ "\x84\x9f\x14\xa8\x53\x81\x0b\xc3\x64\x80\xa3\x02\x0a\x41\x75\xf8"
++ "\x44\x85\x93\x81\x22\x3c\xd8\x13\xe1\xbe\xf4\x59\x91\x1f\x6a\x44"
++ "\x77\x5c\x69\xc4\x2f\x39\x5f\x0f\x2a\x8d\xeb\xba\xf8\xc3\x56\x6c"
++ "\x3b\x36\xa7\xda\xbd\x4d\xa1\xb5\x4e\xc6\xa7\xa4\x3a\xec\x15\x2d"
++ "\xa5\xb3\xea\x5a\xdc\xac\x46\xac\x01\x60\xd8\x43\xc8\x8e\x8b\xb1"
++ "\x40\x4c\x95\x8b\x34\x41\x28\x52\x91\x28\x43\xd3\xa3\xb6\xa7\x55"
++ "\x15\xe7\x5a\x96\xcb\xf1\xda\xe5\x55\xee\xfe\x1e\xbd\xd9\x41\xd3"
++ "\x28\xfd\x97\xca\x57\x2b\x85\x9c\xa4\x30\x95\xaa\xa5\x57\xa2\x35"
++ "\x15\x86\xcb\x61\x34\x41\xe4\xc7\x80\x20\x18\x21\x17\x09\x85\x0b"
++ "\x14\x9d\x21\x68\x62\x1c\x08\x11\x64\x4b\x92\xf2\xd2\xd3\x2d\x2d"
++ "\x6a\xc2\x73\x6b\x3c\x3c\x8b\x9e\xbc\x52\xaa\xa4\xab\x81\x6c\xf6"
++ "\xfa\xbd\x70\xc5\xc6\x7b\xc2\xaa\x22\x4f\x58\x04\x87\x25\x6a\x27"
++ "\x1d\xa4\x3d\x20\x75\x72\x01\x09\x71\xe5\x1c\x9e\xc3\x2e\x36\xf3"
++ "\xd0\xc6\x35\x2a\x43\x4d\x2d\x0e\x2d\xb4\xa1\x49\xce\x65\x1e\x52"
++ "\x9e\xa1\xf6\x09\xcc\xdc\x63\x66\xa8\x01\xe9\x3b\x0d\xd7\x5a\x85"
++ "\xbb\xc5\x65\xc0\x7b\x2e\x46\xa9\xd9\x56\x1d\x4c\x92\x72\x26\x4e"
++ "\x86\xd5\x68\xae\xc4\xaa\x55\xce\xd7\x83\x59\xb3\x81\xee\xce\x74"
++ "\x39\x39\x31\x9f\x8a\x25\xe8\xa5\xa5\xe5\x81\xf2\x11\x23\xcb\xa1"
++ "\x1e\x43\x12\xe3\xb1\x2a\x2b\xcd\xc8\x8d\x25\x96\xa4\x47\x7d\x95"
++ "\xa5\xc6\x9f\x61\xe4\x25\xc6\x5e\x69\xc4\xe7\x29\x5b\x6e\xb6\xa4"
++ "\xad\x0b\x4e\x72\x95\x25\x58\x56\x33\x9c\x67\xce\xef\x0f\x17\xbf"
++ "\x4c\x7b\x2d\xe6\xfe\x76\x35\x27\x5a\x07\x97\x67\xe8\xae\x8d\x71"
++ "\x0f\xb2\x13\x99\xb9\xbc\x14\xad\xb3\xb7\xe6\x11\x6f\xe0\xda\x58"
++ "\xb1\x08\xac\xa6\x6c\x2d\x7f\x05\xb7\x56\xd2\xe6\xcf\xbb\x4d\x0c"
++ "\xe3\x50\xb2\xec\x91\xf0\x4a\xb8\xd6\x22\xb8\xa7\xf6\x67\xaf\xcf"
++ "\x63\x7e\xd7\xe7\x42\xd8\xbd\xc3\x71\xa1\xf2\x7e\x9b\xa8\x97\x83"
++ "\x6e\xd1\xdc\x4b\x06\x11\x2d\xae\x26\x61\x98\x72\x10\xf4\x42\x5d"
++ "\x20\x4a\xa3\x73\xd7\xf2\xcd\x3c\x48\x32\xe4\x03\x9f\x80\x37\x08"
++ "\x36\x11\xd0\xcb\x97\x6c\x08\xed\x6d\x33\x24\xa2\x1b\xb4\x77\xdf"
++ "\x61\x5d\x5f\xc1\x43\xc2\x82\xeb\x0f\x5d\x84\x08\x68\xaa\xa4\x01"
++ "\xe1\x19\xdf\xbc\x31\x65\xfe\xd1\xf5\x7d\x7a\xb2\x2a\x33\x50\x21"
++ "\x2a\x56\x9d\xb1\x81\xab\xdb\x35\x78\x30\x83\xd9\x89\x1d\x31\xac"
++ "\x96\x14\x07\x61\xbc\x20\x68\x42\x85\x33\x19\xac\xbe\xdb\x34\x56"
++ "\xf1\xd5\xfd\x29\xa9\x28\xdb\xcb\x4c\x5a\x23\xdc\xf5\x96\xc5\x10"
++ "\xa3\x35\x5b\x14\x68\xd3\x61\x62\x64\x76\x26\xcb\x17\x3e\x34\x98"
++ "\x04\xa3\xc4\x20\x38\x90\x92\xe3\xc8\x07\x2c\x36\x74\x66\x26\x0e"
++ "\x29\x02\x64\x29\x2d\x21\xe6\x16\x9c\x6b\xce\xa3\x89\xd9\x4f\xd3"
++ "\xc4\xbd\xc5\x87\x79\x9c\x65\xf6\x39\x45\x60\xe8\xce\x9e\xab\x6d"
++ "\x13\x15\x22\xe1\x5e\x4b\x38\x42\xc4\x1e\xd5\x76\xe0\xc5\xeb\x85"
++ "\x07\x2d\x0f\xb8\xb6\xa6\xd6\x6d\x71\x0d\xa2\x43\x4c\x25\xea\xfa"
++ "\xa1\xae\x4c\xe4\x7d\xbd\x76\xa9\xfb\x06\xc2\x83\x42\xeb\xad\xe7"
++ "\xe9\x5f\x68\x6f\xba\xfb\x2f\x07\xce\xb8\x13\xc1\x9b\xeb\xb0\x76"
++ "\x45\x57\x28\x7b\xea\xbe\x0f\xf4\x30\x7b\xa0\xed\xe4\x22\x93\x21"
++ "\xfc\xbc\xe0\xb9\x75\xc1\x4f\xfc\xef\xb6\xfa\xa1\xfc\x64\xa1\x4a"
++ "\x82\xc7\x33\xad\x75\xed\x82\xbd\x3d\xdb\xf7\xa8\xbe\x5e\xbb\x36"
++ "\x62\x04\x9a\x2e\xc5\xd9\x9e\x9c\x3a\x0b\x98\x0b\x57\xac\xf1\x24"
++ "\x62\x58\x83\x15\x5b\xa6\xf2\xda\x34\x70\x03\xce\x0f\x93\x1b\x12"
++ "\xc7\xce\x54\x87\x33\x15\xd6\x53\x25\x1f\x2a\x90\x87\x12\xe3\x78"
++ "\xef\x55\x77\x4d\x4a\xd8\x7e\xef\xd2\xfd\xd1\xaf\x3a\xaf\x55\xdb"
++ "\x6a\x2d\x3d\x42\xac\x51\x79\xee\x91\xab\xe1\x05\x2d\x3c\x80\xa2"
++ "\x43\xad\x22\x2e\xd5\x33\x13\xa4\x9e\x00\xe0\x04\x10\x84\xc8\xf2"
++ "\x19\x30\x92\x1f\xaa\xc3\x28\xc9\x76\x30\x3f\xe9\x10\x61\x5e\x79"
++ "\xd5\xf7\xdf\xd0\x54\xdb\xae\xb6\xae\xfa\xe8\xa3\x57\xe0\x6c\x2d"
++ "\xf7\xbd\x49\xd6\x6e\x76\x79\xcc\x54\x0c\x5f\xff\x00\xbb\x06\x98"
++ "\xa6\x9e\x89\x61\xb4\x6f\xc3\xe3\x6a\xc2\x4f\x59\x03\xc9\x80\x2c"
++ "\x59\x24\x44\x70\x38\xd5\x96\x6a\x9e\x8b\x81\x64\xe5\xbc\xa0\x3c"
++ "\x33\xaf\x17\x9d\xff\x00\x71\x1a\xd1\x3a\x80\x66\xb3\xd9\x31\x77"
++ "\x0d\x12\xbd\xae\x29\xb5\x6a\xd6\xcf\x8d\x68\x87\x75\xcd\xe8\x65"
++ "\x5a\xbe\x3c\x04\x7b\x34\xdb\x54\x19\xa4\x63\x9c\x2a\x5d\x23\xbe"
++ "\xf4\xb1\x1c\x4d\x90\xec\x92\x2f\x49\x71\xf7\x14\xf2\x97\x9f\x15"
++ "\x57\xed\x13\x21\x2a\xf5\x33\xd1\x2a\x52\x52\xac\xb7\x62\xd1\xcb"
++ "\x46\x73\x8c\x67\x28\x56\x77\x86\xbf\x6f\x2a\x4e\x73\xfe\x95\x65"
++ "\x0b\x5a\x3e\x38\xfc\xfc\xaa\x56\x3f\x86\x73\xe3\xb9\x4a\x52\x84"
++ "\xa5\x08\x4e\x12\x94\x27\x09\x4a\x53\x8c\x61\x29\x4a\x71\xf0\x4a"
++ "\x53\x8c\x7e\x31\x8c\x63\x18\xc6\x31\x8f\xc6\x31\xf8\xc7\x9f\x7c"
++ "\xd5\xbb\xae\x5e\xe2\x1f\xab\x6e\x24\x34\x00\x8a\x25\x83\x70\x40"
++ "\x1c\xcc\xda\x45\x7f\x66\x4e\x30\x2e\x94\x7e\x74\x49\xf0\xe4\x4e"
++ "\x06\x5c\xa8\x2f\x89\x21\x2e\x98\x0e\xd9\x21\xc2\x0b\x21\x0f\xc4"
++ "\x16\x6e\x48\xd9\xe4\xe3\x4a\x19\x1e\x64\x67\x54\xff\x00\x3a\x6d"
++ "\x4f\x62\xb5\x00\x4a\xaa\x51\xfd\x2d\xe8\x0e\x6c\xaf\xc6\x7d\x6d"
++ "\xc8\x88\xc7\x67\xea\x8a\x58\x02\x73\xe3\x65\x4d\xc9\x24\xc0\x3d"
++ "\x57\xa3\x2e\x53\x16\x99\x4f\xe5\xe7\x19\x97\x3e\x3b\xcf\xc9\x4b"
++ "\x99\x7f\x33\x25\xa5\xdf\xba\x77\x2b\xd3\x3e\xc2\x7b\x8b\x94\x07"
++ "\xe9\x52\x5b\x43\x87\x34\x14\x86\x37\xcf\x41\x6b\x8e\x6a\xa5\x22"
++ "\xab\xdb\x96\xa2\xcf\x46\xd8\x9b\x45\x93\xef\xd6\xdf\x3e\x99\x9c"
++ "\x7e\x29\x10\x6b\x6c\xa2\xb8\x43\x05\x09\x44\x70\x8c\xb8\xaa\x54"
++ "\x7c\x30\x36\x5e\x1c\x5e\x5b\x9f\x6c\x0d\x81\xee\xa0\x93\x8d\x67"
++ "\x55\xf3\x87\xaf\xaa\x6b\x58\xf9\xbe\xb2\x36\x07\x42\x6e\xbd\x96"
++ "\xe3\x9f\x1f\x8f\xc9\xf4\x9d\xae\x6a\x7d\x4c\x96\xbe\x5f\xc7\xcd"
++ "\xf3\xb2\xf7\xcd\xf0\xcf\xc3\xe4\xf8\xfe\x37\x4f\x1c\x4d\xf6\x40"
++ "\xf1\x6b\x7c\x4e\xe0\xa6\x71\xad\x56\xa7\x1c\x5c\x15\x6b\xfc\xf3"
++ "\x01\x5d\xac\xf1\x75\x9a\x72\x6b\xaa\x28\xc5\x88\x6d\xfb\x33\x85"
++ "\xe0\x4e\x61\xab\xeb\x31\x2c\x71\x08\x73\x11\x3b\xfc\xb5\xc0\x96"
++ "\xcc\x87\x24\x44\xb5\x9b\x9e\xb3\x71\xba\xe9\xed\xb1\x4e\xd7\x76"
++ "\x6c\xd2\xb6\x05\xb7\x5a\xde\xeb\x34\x5b\x96\x16\xfb\x59\xa9\x5c"
++ "\x4f\x55\xca\x8a\xac\x59\xb0\xe4\x54\x39\x25\xbc\x81\x37\x2a\x09"
++ "\x5f\x9e\x3b\x6b\x7d\x1f\x69\xf3\x34\x85\x39\x84\xa7\x28\x0b\xd3"
++ "\xfd\xfb\x4b\x7a\xea\xe7\xd2\x3c\xd3\xda\x15\x68\xbc\x73\xd3\x22"
++ "\x6f\xd7\x72\x5b\x2b\x66\xee\xa8\x0d\x54\xe8\x5b\xf9\x92\x96\x92"
++ "\x93\xea\x97\x4a\xc7\x43\x10\x46\x35\xc5\xc0\x60\x8a\xe4\xc1\xb5"
++ "\x36\xc6\xae\xed\xf7\x70\xa5\x86\x99\x3d\x91\xf8\xfd\x4e\x53\xeb"
++ "\xbb\xbd\x6d\xec\x8f\xd7\x89\x3d\x31\x7f\xd7\x78\xba\x50\xbb\x74"
++ "\x9d\xf6\xac\x4e\xb9\x03\x9c\x79\xd5\xe1\xbd\x17\x68\xd9\x13\x0b"
++ "\x45\x75\x88\x00\x1d\x1f\xae\x73\x6a\x1d\x5c\x6e\x44\x9f\xa6\xfa"
++ "\x4e\xd8\x25\x8b\xc0\xbc\xb2\x99\xe3\x17\x24\xb3\x23\xe2\x48\x8b"
++ "\xfa\x22\xe7\x7e\x8f\xe6\x3f\x5f\x55\x0d\x75\xd3\x51\x0b\xd7\xed"
++ "\xd3\x6f\x97\x3b\x85\x42\x80\x7e\x5f\xdc\x1b\xd6\xba\xee\xc4\x80"
++ "\xce\x06\xa9\x15\x8c\x97\x5f\x40\x69\xb2\x4d\xc5\xb2\x5c\x1e\x01"
++ "\x87\x7e\xe0\x36\x6d\x78\x80\x4e\x3c\x02\xec\x90\x1d\x11\x81\x74"
++ "\xa5\x8b\xa4\xa0\x56\x06\xd5\x79\x72\x85\x57\x3b\xb2\x2e\xae\x90"
++ "\x18\x8d\x91\xb2\x0e\x44\x19\xaa\xb4\xcc\x08\xed\x46\xfa\xd7\x2b"
++ "\x78\x58\x72\x5d\xbb\x5e\x49\xe7\xee\xf3\x8a\x9d\x22\xa4\x19\xc8"
++ "\xe7\x08\xc3\x90\x9b\x35\x9a\xa4\x25\x8c\x4b\x9b\xa7\xf8\xbf\x81"
++ "\xf5\xdf\x22\x66\xf1\x7e\x9f\x66\x3d\xbb\xfa\x73\x73\x4d\xfd\x67"
++ "\x7b\xf4\xce\xc3\x62\x2e\x6f\xbb\x0c\xa2\xdc\x69\xfc\x8a\x17\x0e"
++ "\x3a\x9e\x83\x46\xd7\xe3\x5e\x65\x86\xc0\x51\x00\xbb\x91\xe3\xe1"
++ "\xc1\x16\xc4\xe9\x65\x5c\x14\x3e\x44\x6a\x6b\xd1\x1e\xb0\x36\xdd"
++ "\x0b\x7d\x8a\xeb\xaf\x58\x5b\x64\x3f\x38\xed\x52\x76\xe8\x46\xf7"
++ "\x86\x84\xb3\x93\xb1\x0b\xe5\xfd\xfd\x0d\xe9\x6d\xe4\xf1\x1b\x1d"
++ "\x56\xb4\x34\xe4\x6a\xf5\xa4\x9c\x2c\xc9\x64\x94\xc1\xf5\x79\x6d"
++ "\x12\x96\xf3\x47\xc5\x48\xa8\xdb\xd8\x95\x64\x29\xcf\xf6\x88\xf1"
++ "\x95\x7a\x98\xe8\xbc\x27\x19\xce\x73\x61\xd1\xb8\xc6\x31\x8c\xe7"
++ "\x39\xce\x77\x9e\xbc\xc6\x31\x8c\x63\xf3\x9c\xe7\x39\xc6\x31\x8f"
++ "\xf7\xce\x7e\x1e\x3b\x7f\x0f\x0f\x0f\x13\x57\xb9\x0a\xe1\x0b\x64"
++ "\x5f\x58\x40\xc6\xc7\x7a\x4b\xf2\x3d\xbc\x71\xf4\xa7\xd2\xca\x14"
++ "\xe2\x98\x1a\x30\x1e\xe0\x26\x5a\x6a\xf0\x9c\x67\x38\x66\x00\xb8"
++ "\x72\xe6\xbe\xac\xfe\x12\xd3\x0b\x56\x73\x8c\x63\xc7\x2b\xe1\xe2"
++ "\xe8\xdd\x7b\xff\x00\xd8\xe5\x23\x6c\xce\xa8\x69\xcf\x5e\x3a\xef"
++ "\x77\xea\xe5\xab\x0e\x82\xdb\xd9\xed\x7a\x9e\xb8\x6d\x51\x32\xdb"
++ "\x79\xc3\x36\x9a\x2d\xa3\x50\x39\x65\x0a\x63\x0e\xe5\xd4\x39\x12"
++ "\xbf\x8b\x98\xa4\xa1\x2d\xad\xb3\xcf\x65\x6a\x43\x78\xb3\x3b\x07"
++ "\xd8\xd5\xea\xae\x76\xad\x6f\xf5\xff\x00\xca\x93\xab\x96\xb0\x64"
++ "\xeb\xd6\x4a\xd5\x87\xba\xec\x24\x60\x97\x06\x76\x03\xe3\x4c\x07"
++ "\x29\x11\x8e\x34\x25\x02\x64\x29\xf0\x25\x48\x85\x3a\x33\x8b\x7a"
++ "\x3c\x86\x1e\x75\xa5\x61\xc6\x97\x9f\x8d\x25\xf5\xc9\xcd\xde\xc9"
++ "\x7d\x77\xf2\xc8\x7e\x70\xaf\x73\x5f\x2d\xec\xa2\x51\x2d\x96\xfb"
++ "\x89\xad\x80\x57\xb2\x36\x1d\x7d\x83\x45\xac\xf3\xdb\xcc\x6c\x31"
++ "\x4f\xcf\x30\x58\xd0\x12\x28\x90\x50\x42\x86\xfb\x48\x16\x3c\xc5"
++ "\x9c\xf8\xe7\xcc\x29\x88\xb3\x4a\x4b\x4e\x6c\xbc\xdb\xc7\xbb\xe9"
++ "\xb6\xa0\x8b\x11\xa1\x7d\x73\xd7\xe9\xbf\x7e\xc2\x6c\x10\x8d\xee"
++ "\x9d\xef\x63\x3a\xe0\xf5\xbe\x8c\x3e\xa1\xc7\xc5\xd1\x00\x44\x1e"
++ "\xf3\x51\xf2\xe2\xb0\xe3\xb5\x13\x7f\x32\xf1\x8c\xa6\x22\xfe\x1f"
++ "\x49\x4d\xbb\xcf\x3a\x5d\xed\x4c\xd2\xfc\x85\xed\x23\xd6\xc7\x50"
++ "\xb6\x5b\x3a\x16\x83\xb8\x6f\xfd\x32\x3f\xaa\x36\x34\xbb\xf5\x96"
++ "\xa9\xab\xcf\x9f\x8f\xac\xc3\xca\xd5\x8b\xd8\x48\x9e\x79\xaa\x30"
++ "\x87\xca\x58\x4d\x59\x96\xb9\x4f\xc5\x1b\x1c\xd2\xda\x5b\xe6\x57"
++ "\x29\xa1\x28\x7a\x2b\x5b\xff\x00\x12\x2f\x5e\x3f\xf3\xbb\x8e\x7f"
++ "\xec\xc6\x98\xff\x00\xed\x3c\xa6\xdd\xa9\xdc\x7e\xa0\xf7\xd6\x99"
++ "\x31\xa2\xf7\xaf\x6b\xe9\x82\x74\x4b\x3d\x8f\x5e\x58\x0b\x33\xab"
++ "\xef\xc3\xaf\x84\x64\xb9\xae\xb6\x25\x5f\x62\x8f\x1c\xe3\xf4\x51"
++ "\xb7\x96\xe3\x0e\x30\x42\xa9\x18\x39\xbf\x9e\x2a\x1f\x74\x19\x02"
++ "\x2d\x43\x93\x06\x63\xb1\xa7\x47\x6a\xfa\x9b\x6c\xeb\xbd\xe9\xae"
++ "\x6a\x7b\x6f\x53\x5a\x60\x5d\xb5\xcd\xe8\x67\xeb\x35\x3b\x48\xc6"
++ "\xa6\xb3\x04\xc8\xdf\xb8\x7e\x26\x64\xb0\xc9\x18\xb0\xa7\x33\xf2"
++ "\x4a\x8b\x22\x3b\x8d\x4b\x89\x1d\xf6\x9d\x65\xc4\x38\xd2\x54\x9c"
++ "\xe3\xcd\x89\xe1\xe1\xe6\x3e\x70\x81\x45\x1d\x18\xf9\x31\x83\xc8"
++ "\xbe\x14\x82\x4b\x87\x7a\x74\x28\xd2\xdd\x12\x55\x30\xe6\x0e\x49"
++ "\x31\x8e\x48\x69\xc5\xc0\x20\x91\xe4\x48\x41\x4c\xd8\xb9\x6a\x4e"
++ "\x21\xce\x99\x1b\x0e\xfd\x09\x4f\xa1\x79\x0f\x0f\x0f\x0f\x0f\x0f"
++ "\x0f\x3f\x3c\xb8\x71\x27\xc7\x72\x24\xe8\xb1\xa6\xc5\x7b\x18\xc3"
++ "\xb1\xa5\xb0\xd4\x98\xee\xe3\x19\xc6\x71\x87\x19\x79\x2b\x6d\x78"
++ "\xc6\x71\x8c\xe3\x0a\x4e\x71\x8c\xe3\x19\xfe\x38\xf2\x3b\xfb\x8b"
++ "\x48\xfe\x4e\xaa\xff\x00\x4f\x08\xff\x00\xc7\xe1\xfb\x8b\x48\xfe"
++ "\x4e\xaa\xff\x00\x4f\x08\xff\x00\xc7\xe4\x95\x86\x18\x8a\xcb\x31"
++ "\xa3\x32\xd4\x78\xf1\xdb\x43\x2c\x47\x61\xb4\x32\xcb\x2c\xb4\x9c"
++ "\x21\xb6\x99\x69\xbc\x25\xb6\xdb\x6d\x18\xc2\x10\xda\x12\x94\xa1"
++ "\x38\xc2\x53\x8c\x63\x18\xc7\x9d\xbe\x7f\xff\xd9"
++ ;
+diff -Naurp php-5.3.6RC1/main/suhosin_patch.c php-5.3.6RC1.oden/main/suhosin_patch.c
+--- php-5.3.6RC1/main/suhosin_patch.c 1970-01-01 01:00:00.000000000 +0100
++++ php-5.3.6RC1.oden/main/suhosin_patch.c 2011-02-20 11:50:19.307837147 +0100
+@@ -0,0 +1,470 @@
++/*
++ +----------------------------------------------------------------------+
++ | Suhosin Patch for PHP |
++ +----------------------------------------------------------------------+
++ | Copyright (c) 2004-2010 Stefan Esser |
++ +----------------------------------------------------------------------+
++ | This source file is subject to version 2.02 of the PHP license, |
++ | that is bundled with this package in the file LICENSE, and is |
++ | available at through the world-wide-web at |
++ | http://www.php.net/license/2_02.txt. |
++ | If you did not receive a copy of the PHP license and are unable to |
++ | obtain it through the world-wide-web, please send a note to |
++ | license@php.net so we can mail you a copy immediately. |
++ +----------------------------------------------------------------------+
++ | Author: Stefan Esser <sesser@hardened-php.net> |
++ +----------------------------------------------------------------------+
++ */
++/* $Id$ */
++
++#include "php.h"
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <sys/mman.h>
++
++#if HAVE_UNISTD_H
++#include <unistd.h>
++#endif
++#include "SAPI.h"
++#include "php_globals.h"
++
++#if SUHOSIN_PATCH
++
++#ifdef HAVE_SYS_SOCKET_H
++#include <sys/socket.h>
++#endif
++
++#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
++#undef AF_UNIX
++#endif
++
++#if defined(AF_UNIX)
++#include <sys/un.h>
++#endif
++
++#define SYSLOG_PATH "/dev/log"
++
++#ifdef PHP_WIN32
++static HANDLE log_source = 0;
++#endif
++
++#include "snprintf.h"
++
++#include "suhosin_patch.h"
++
++#ifdef ZTS
++#include "suhosin_globals.h"
++int suhosin_patch_globals_id;
++#else
++struct _suhosin_patch_globals suhosin_patch_globals;
++#endif
++
++static char *suhosin_config = NULL;
++
++static zend_intptr_t SUHOSIN_POINTER_GUARD = 0;
++
++static void php_security_log(int loglevel, char *fmt, ...);
++
++static void suhosin_patch_globals_ctor(suhosin_patch_globals_struct *suhosin_patch_globals TSRMLS_DC)
++{
++ memset(suhosin_patch_globals, 0, sizeof(*suhosin_patch_globals));
++}
++
++ZEND_API char suhosin_get_config(int element)
++{
++ return ((char *)SUHOSIN_MANGLE_PTR(suhosin_config))[element];
++}
++
++static void suhosin_set_config(int element, char value)
++{
++ ((char *)SUHOSIN_MANGLE_PTR(suhosin_config))[element] = value;
++}
++
++static void suhosin_read_configuration_from_environment()
++{
++ char *tmp;
++
++ /* check if canary protection should be activated or not */
++ tmp = getenv("SUHOSIN_MM_USE_CANARY_PROTECTION");
++ /* default to activated */
++ suhosin_set_config(SUHOSIN_MM_USE_CANARY_PROTECTION, 1);
++ if (tmp) {
++ int flag = zend_atoi(tmp, 0);
++ suhosin_set_config(SUHOSIN_MM_USE_CANARY_PROTECTION, flag);
++ }
++
++ /* check if free memory should be overwritten with 0xFF or not */
++ tmp = getenv("SUHOSIN_MM_DESTROY_FREE_MEMORY");
++ /* default to deactivated */
++ suhosin_set_config(SUHOSIN_MM_DESTROY_FREE_MEMORY, 0);
++ if (tmp) {
++ int flag = zend_atoi(tmp, 0);
++ suhosin_set_config(SUHOSIN_MM_DESTROY_FREE_MEMORY, flag);
++ }
++
++ /* check if canary violations should be ignored */
++ tmp = getenv("SUHOSIN_MM_IGNORE_CANARY_VIOLATION");
++ /* default to NOT ignore */
++ suhosin_set_config(SUHOSIN_MM_IGNORE_CANARY_VIOLATION, 0);
++ if (tmp) {
++ int flag = zend_atoi(tmp, 0);
++ suhosin_set_config(SUHOSIN_MM_IGNORE_CANARY_VIOLATION, flag);
++ }
++
++ /* check if invalid hashtable destructors should be ignored */
++ tmp = getenv("SUHOSIN_HT_IGNORE_INVALID_DESTRUCTOR");
++ /* default to NOT ignore */
++ suhosin_set_config(SUHOSIN_HT_IGNORE_INVALID_DESTRUCTOR, 0);
++ if (tmp) {
++ int flag = zend_atoi(tmp, 0);
++ suhosin_set_config(SUHOSIN_HT_IGNORE_INVALID_DESTRUCTOR, flag);
++ }
++
++ /* check if invalid linkedlist destructors should be ignored */
++ tmp = getenv("SUHOSIN_LL_IGNORE_INVALID_DESTRUCTOR");
++ /* default to NOT ignore */
++ suhosin_set_config(SUHOSIN_LL_IGNORE_INVALID_DESTRUCTOR, 0);
++ if (tmp) {
++ int flag = zend_atoi(tmp, 0);
++ suhosin_set_config(SUHOSIN_LL_IGNORE_INVALID_DESTRUCTOR, flag);
++ }
++
++ suhosin_set_config(SUHOSIN_CONFIG_SET, 1);
++}
++
++static void suhosin_write_protect_configuration()
++{
++ /* check return value of mprotect() to ensure memory is read only now */
++ if (mprotect(SUHOSIN_MANGLE_PTR(suhosin_config), sysconf(_SC_PAGESIZE), PROT_READ) != 0) {
++ perror("suhosin");
++ _exit(1);
++ }
++}
++
++PHPAPI void suhosin_startup()
++{
++#ifdef ZTS
++ ts_allocate_id(&suhosin_patch_globals_id, sizeof(suhosin_patch_globals_struct), (ts_allocate_ctor) suhosin_patch_globals_ctor, NULL);
++#else
++ suhosin_patch_globals_ctor(&suhosin_patch_globals TSRMLS_CC);
++#endif
++ zend_suhosin_log = php_security_log;
++
++ /* get the pointer guardian and ensure low 3 bits are 1 */
++ if (SUHOSIN_POINTER_GUARD == 0) {
++ zend_canary(&SUHOSIN_POINTER_GUARD, sizeof(SUHOSIN_POINTER_GUARD));
++ SUHOSIN_POINTER_GUARD |= 7;
++ }
++
++ if (!suhosin_config) {
++#ifndef MAP_ANONYMOUS
++#define MAP_ANONYMOUS MAP_ANON
++#endif
++ suhosin_config = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
++ if (suhosin_config == MAP_FAILED) {
++ perror("suhosin");
++ _exit(1);
++ }
++ suhosin_config = SUHOSIN_MANGLE_PTR(suhosin_config);
++ }
++ if (!SUHOSIN_CONFIG(SUHOSIN_CONFIG_SET)) {
++ suhosin_read_configuration_from_environment();
++ suhosin_write_protect_configuration();
++ }
++}
++
++static char *loglevel2string(int loglevel)
++{
++ switch (loglevel) {
++ case S_FILES:
++ return "FILES";
++ case S_INCLUDE:
++ return "INCLUDE";
++ case S_MEMORY:
++ return "MEMORY";
++ case S_MISC:
++ return "MISC";
++ case S_SESSION:
++ return "SESSION";
++ case S_SQL:
++ return "SQL";
++ case S_EXECUTOR:
++ return "EXECUTOR";
++ case S_VARS:
++ return "VARS";
++ default:
++ return "UNKNOWN";
++ }
++}
++
++static void php_security_log(int loglevel, char *fmt, ...)
++{
++ int s, r, i=0;
++#if defined(AF_UNIX)
++ struct sockaddr_un saun;
++#endif
++#ifdef PHP_WIN32
++ LPTSTR strs[2];
++ unsigned short etype;
++ DWORD evid;
++#endif
++ char buf[4096+64];
++ char error[4096+100];
++ char *ip_address;
++ char *fname;
++ char *alertstring;
++ int lineno;
++ va_list ap;
++ TSRMLS_FETCH();
++
++ /*SDEBUG("(suhosin_log) loglevel: %d log_syslog: %u - log_sapi: %u - log_script: %u", loglevel, SPG(log_syslog), SPG(log_sapi), SPG(log_script));*/
++
++ if (SPG(log_use_x_forwarded_for)) {
++ ip_address = sapi_getenv("HTTP_X_FORWARDED_FOR", 20 TSRMLS_CC);
++ if (ip_address == NULL) {
++ ip_address = "X-FORWARDED-FOR not set";
++ }
++ } else {
++ ip_address = sapi_getenv("REMOTE_ADDR", 11 TSRMLS_CC);
++ if (ip_address == NULL) {
++ ip_address = "REMOTE_ADDR not set";
++ }
++ }
++
++
++ va_start(ap, fmt);
++ ap_php_vsnprintf(error, sizeof(error), fmt, ap);
++ va_end(ap);
++ while (error[i]) {
++ if (error[i] < 32) error[i] = '.';
++ i++;
++ }
++
++/* if (SPG(simulation)) {
++ alertstring = "ALERT-SIMULATION";
++ } else { */
++ alertstring = "ALERT";
++/* }*/
++
++ if (zend_is_executing(TSRMLS_C)) {
++ if (EG(current_execute_data)) {
++ lineno = EG(current_execute_data)->opline->lineno;
++ fname = EG(current_execute_data)->op_array->filename;
++ } else {
++ lineno = zend_get_executed_lineno(TSRMLS_C);
++ fname = zend_get_executed_filename(TSRMLS_C);
++ }
++ ap_php_snprintf(buf, sizeof(buf), "%s - %s (attacker '%s', file '%s', line %u)", alertstring, error, ip_address, fname, lineno);
++ } else {
++ fname = sapi_getenv("SCRIPT_FILENAME", 15 TSRMLS_CC);
++ if (fname==NULL) {
++ fname = "unknown";
++ }
++ ap_php_snprintf(buf, sizeof(buf), "%s - %s (attacker '%s', file '%s')", alertstring, error, ip_address, fname);
++ }
++
++ /* Syslog-Logging disabled? */
++ if (((SPG(log_syslog)|S_INTERNAL) & loglevel)==0) {
++ goto log_sapi;
++ }
++
++#if defined(AF_UNIX)
++ ap_php_snprintf(error, sizeof(error), "<%u>suhosin[%u]: %s\n", (unsigned int)(SPG(log_syslog_facility)|SPG(log_syslog_priority)),getpid(),buf);
++
++ s = socket(AF_UNIX, SOCK_DGRAM, 0);
++ if (s == -1) {
++ goto log_sapi;
++ }
++
++ memset(&saun, 0, sizeof(saun));
++ saun.sun_family = AF_UNIX;
++ strcpy(saun.sun_path, SYSLOG_PATH);
++ /*saun.sun_len = sizeof(saun);*/
++
++ r = connect(s, (struct sockaddr *)&saun, sizeof(saun));
++ if (r) {
++ close(s);
++ s = socket(AF_UNIX, SOCK_STREAM, 0);
++ if (s == -1) {
++ goto log_sapi;
++ }
++
++ memset(&saun, 0, sizeof(saun));
++ saun.sun_family = AF_UNIX;
++ strcpy(saun.sun_path, SYSLOG_PATH);
++ /*saun.sun_len = sizeof(saun);*/
++
++ r = connect(s, (struct sockaddr *)&saun, sizeof(saun));
++ if (r) {
++ close(s);
++ goto log_sapi;
++ }
++ }
++ send(s, error, strlen(error), 0);
++
++ close(s);
++#endif
++#ifdef PHP_WIN32
++ ap_php_snprintf(error, sizeof(error), "suhosin[%u]: %s", getpid(),buf);
++
++ switch (SPG(log_syslog_priority)) { /* translate UNIX type into NT type */
++ case 1: /*LOG_ALERT:*/
++ etype = EVENTLOG_ERROR_TYPE;
++ break;
++ case 6: /*LOG_INFO:*/
++ etype = EVENTLOG_INFORMATION_TYPE;
++ break;
++ default:
++ etype = EVENTLOG_WARNING_TYPE;
++ }
++ evid = loglevel;
++ strs[0] = error;
++ /* report the event */
++ if (log_source == NULL) {
++ log_source = RegisterEventSource(NULL, "Suhosin-Patch-" SUHOSIN_PATCH_VERSION);
++ }
++ ReportEvent(log_source, etype, (unsigned short) SPG(log_syslog_priority), evid, NULL, 1, 0, strs, NULL);
++
++#endif
++log_sapi:
++ /* SAPI Logging activated? */
++ /*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));*/
++ if (((SPG(log_sapi)|S_INTERNAL) & loglevel)!=0) {
++ sapi_module.log_message(buf);
++ }
++
++/*log_script:*/
++ /* script logging activaed? */
++ if (((SPG(log_script) & loglevel)!=0) && SPG(log_scriptname)!=NULL) {
++ char cmd[8192], *cmdpos, *bufpos;
++ FILE *in;
++ int space;
++
++ ap_php_snprintf(cmd, sizeof(cmd), "%s %s \'", SPG(log_scriptname), loglevel2string(loglevel));
++ space = sizeof(cmd) - strlen(cmd);
++ cmdpos = cmd + strlen(cmd);
++ bufpos = buf;
++ if (space <= 1) return;
++ while (space > 2 && *bufpos) {
++ if (*bufpos == '\'') {
++ if (space<=5) break;
++ *cmdpos++ = '\'';
++ *cmdpos++ = '\\';
++ *cmdpos++ = '\'';
++ *cmdpos++ = '\'';
++ bufpos++;
++ space-=4;
++ } else {
++ *cmdpos++ = *bufpos++;
++ space--;
++ }
++ }
++ *cmdpos++ = '\'';
++ *cmdpos = 0;
++
++ if ((in=VCWD_POPEN(cmd, "r"))==NULL) {
++ php_security_log(S_INTERNAL, "Unable to execute logging shell script: %s", SPG(log_scriptname));
++ return;
++ }
++ /* read and forget the result */
++ while (1) {
++ int readbytes = fread(cmd, 1, sizeof(cmd), in);
++ if (readbytes<=0) {
++ break;
++ }
++ }
++ pclose(in);
++ }
++/*log_phpscript:*/
++ if ((SPG(log_phpscript) & loglevel)!=0 && EG(in_execution) && SPG(log_phpscriptname) && SPG(log_phpscriptname)[0]) {
++ zend_file_handle file_handle;
++ zend_op_array *new_op_array;
++ zval *result = NULL;
++
++ /*long orig_execution_depth = SPG(execution_depth);*/
++ zend_bool orig_safe_mode = PG(safe_mode);
++ char *orig_basedir = PG(open_basedir);
++
++ char *phpscript = SPG(log_phpscriptname);
++/*SDEBUG("scriptname %s", SPG(log_phpscriptname));`*/
++#ifdef ZEND_ENGINE_2
++ if (zend_stream_open(phpscript, &file_handle TSRMLS_CC) == SUCCESS) {
++#else
++ if (zend_open(phpscript, &file_handle) == SUCCESS && ZEND_IS_VALID_FILE_HANDLE(&file_handle)) {
++ file_handle.filename = phpscript;
++ file_handle.free_filename = 0;
++#endif
++ if (!file_handle.opened_path) {
++ file_handle.opened_path = estrndup(phpscript, strlen(phpscript));
++ }
++ new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC);
++ zend_destroy_file_handle(&file_handle TSRMLS_CC);
++ if (new_op_array) {
++ HashTable *active_symbol_table = EG(active_symbol_table);
++ zval *zerror, *zerror_class;
++
++ if (active_symbol_table == NULL) {
++ active_symbol_table = &EG(symbol_table);
++ }
++ EG(return_value_ptr_ptr) = &result;
++ EG(active_op_array) = new_op_array;
++
++ MAKE_STD_ZVAL(zerror);
++ MAKE_STD_ZVAL(zerror_class);
++ ZVAL_STRING(zerror, buf, 1);
++ ZVAL_LONG(zerror_class, loglevel);
++
++ zend_hash_update(active_symbol_table, "SUHOSIN_ERROR", sizeof("SUHOSIN_ERROR"), (void **)&zerror, sizeof(zval *), NULL);
++ zend_hash_update(active_symbol_table, "SUHOSIN_ERRORCLASS", sizeof("SUHOSIN_ERRORCLASS"), (void **)&zerror_class, sizeof(zval *), NULL);
++
++ /*SPG(execution_depth) = 0;*/
++ if (SPG(log_phpscript_is_safe)) {
++ PG(safe_mode) = 0;
++ PG(open_basedir) = NULL;
++ }
++
++ zend_execute(new_op_array TSRMLS_CC);
++
++ /*SPG(execution_depth) = orig_execution_depth;*/
++ PG(safe_mode) = orig_safe_mode;
++ PG(open_basedir) = orig_basedir;
++
++#ifdef ZEND_ENGINE_2
++ destroy_op_array(new_op_array TSRMLS_CC);
++#else
++ destroy_op_array(new_op_array);
++#endif
++ efree(new_op_array);
++#ifdef ZEND_ENGINE_2
++ if (!EG(exception))
++#endif
++ {
++ if (EG(return_value_ptr_ptr)) {
++ zval_ptr_dtor(EG(return_value_ptr_ptr));
++ EG(return_value_ptr_ptr) = NULL;
++ }
++ }
++ } else {
++ php_security_log(S_INTERNAL, "Unable to execute logging PHP script: %s", SPG(log_phpscriptname));
++ return;
++ }
++ } else {
++ php_security_log(S_INTERNAL, "Unable to execute logging PHP script: %s", SPG(log_phpscriptname));
++ return;
++ }
++ }
++
++}
++
++
++#endif
++
++/*
++ * Local variables:
++ * tab-width: 4
++ * c-basic-offset: 4
++ * End:
++ * vim600: sw=4 ts=4 fdm=marker
++ * vim<600: sw=4 ts=4
++ */
+diff -Naurp php-5.3.6RC1/main/suhosin_patch.h php-5.3.6RC1.oden/main/suhosin_patch.h
+--- php-5.3.6RC1/main/suhosin_patch.h 1970-01-01 01:00:00.000000000 +0100
++++ php-5.3.6RC1.oden/main/suhosin_patch.h 2011-02-20 11:50:19.308837288 +0100
+@@ -0,0 +1,59 @@
++/*
++ +----------------------------------------------------------------------+
++ | Suhosin Patch for PHP |
++ +----------------------------------------------------------------------+
++ | Copyright (c) 2004-2010 Stefan Esser |
++ +----------------------------------------------------------------------+
++ | This source file is subject to version 2.02 of the PHP license, |
++ | that is bundled with this package in the file LICENSE, and is |
++ | available at through the world-wide-web at |
++ | http://www.php.net/license/2_02.txt. |
++ | If you did not receive a copy of the PHP license and are unable to |
++ | obtain it through the world-wide-web, please send a note to |
++ | license@php.net so we can mail you a copy immediately. |
++ +----------------------------------------------------------------------+
++ | Author: Stefan Esser <stefan.esser@sektioneins.de> |
++ +----------------------------------------------------------------------+
++ */
++
++#ifndef SUHOSIN_PATCH_H
++#define SUHOSIN_PATCH_H
++
++#if SUHOSIN_PATCH
++
++#include "zend.h"
++
++#define SUHOSIN_PATCH_VERSION "0.9.10"
++
++#define SUHOSIN_LOGO_GUID "SUHO8567F54-D428-14d2-A769-00DA302A5F18"
++
++#define SUHOSIN_CONFIG(idx) (suhosin_get_config(idx))
++
++#define SUHOSIN_MM_USE_CANARY_PROTECTION 0
++#define SUHOSIN_MM_DESTROY_FREE_MEMORY 1
++#define SUHOSIN_MM_IGNORE_CANARY_VIOLATION 2
++#define SUHOSIN_HT_IGNORE_INVALID_DESTRUCTOR 3
++#define SUHOSIN_LL_IGNORE_INVALID_DESTRUCTOR 4
++
++#define SUHOSIN_CONFIG_SET 100
++
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <sys/mman.h>
++
++#if defined(DARWIN)
++#include <mach/vm_param.h>
++#endif
++
++#define SUHOSIN_MANGLE_PTR(ptr) (ptr==NULL?NULL:((void *)((zend_intptr_t)(ptr)^SUHOSIN_POINTER_GUARD)))
++
++#endif
++
++#endif /* SUHOSIN_PATCH_H */
++
++/*
++ * Local variables:
++ * tab-width: 4
++ * c-basic-offset: 4
++ * End:
++ */
+diff -Naurp php-5.3.6RC1/main/suhosin_patch.m4 php-5.3.6RC1.oden/main/suhosin_patch.m4
+--- php-5.3.6RC1/main/suhosin_patch.m4 1970-01-01 01:00:00.000000000 +0100
++++ php-5.3.6RC1.oden/main/suhosin_patch.m4 2011-02-20 11:50:19.308837288 +0100
+@@ -0,0 +1,8 @@
++dnl
++dnl $Id$
++dnl
++dnl This file contains Suhosin Patch for PHP specific autoconf functions.
++dnl
++
++AC_DEFINE(SUHOSIN_PATCH, 1, [Suhosin Patch])
++
+diff -Naurp php-5.3.6RC1/sapi/apache/mod_php5.c php-5.3.6RC1.oden/sapi/apache/mod_php5.c
+--- php-5.3.6RC1/sapi/apache/mod_php5.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/sapi/apache/mod_php5.c 2011-02-20 11:50:19.309837429 +0100
+@@ -969,7 +969,11 @@ static void php_init_handler(server_rec
+ {
+ TSRMLS_FETCH();
+ if (PG(expose_php)) {
++#if SUHOSIN_PATCH
++ ap_add_version_component("PHP/" PHP_VERSION " with Suhosin-Patch");
++#else
+ ap_add_version_component("PHP/" PHP_VERSION);
++#endif
+ }
+ }
+ #endif
+diff -Naurp php-5.3.6RC1/sapi/apache2filter/sapi_apache2.c php-5.3.6RC1.oden/sapi/apache2filter/sapi_apache2.c
+--- php-5.3.6RC1/sapi/apache2filter/sapi_apache2.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/sapi/apache2filter/sapi_apache2.c 2011-02-20 11:50:19.309837429 +0100
+@@ -583,7 +583,11 @@ static void php_apache_add_version(apr_p
+ {
+ TSRMLS_FETCH();
+ if (PG(expose_php)) {
++#if SUHOSIN_PATCH
++ ap_add_version_component(p, "PHP/" PHP_VERSION " with Suhosin-Patch");
++#else
+ ap_add_version_component(p, "PHP/" PHP_VERSION);
++#endif
+ }
+ }
+
+diff -Naurp php-5.3.6RC1/sapi/apache2handler/sapi_apache2.c php-5.3.6RC1.oden/sapi/apache2handler/sapi_apache2.c
+--- php-5.3.6RC1/sapi/apache2handler/sapi_apache2.c 2011-02-20 11:45:04.141487654 +0100
++++ php-5.3.6RC1.oden/sapi/apache2handler/sapi_apache2.c 2011-02-20 11:50:19.310837570 +0100
+@@ -407,7 +407,11 @@ static void php_apache_add_version(apr_p
+ {
+ TSRMLS_FETCH();
+ if (PG(expose_php)) {
++#if SUHOSIN_PATCH
++ ap_add_version_component(p, "PHP/" PHP_VERSION " with Suhosin-Patch");
++#else
+ ap_add_version_component(p, "PHP/" PHP_VERSION);
++#endif
+ }
+ }
+
+diff -Naurp php-5.3.6RC1/sapi/apache_hooks/mod_php5.c php-5.3.6RC1.oden/sapi/apache_hooks/mod_php5.c
+--- php-5.3.6RC1/sapi/apache_hooks/mod_php5.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/sapi/apache_hooks/mod_php5.c 2011-02-20 11:50:19.311837711 +0100
+@@ -1256,7 +1256,11 @@ static void php_init_handler(server_rec
+ {
+ TSRMLS_FETCH();
+ if (PG(expose_php)) {
++#if SUHOSIN_PATCH
++ ap_add_version_component("PHP/" PHP_VERSION " with Suhosin-Patch");
++#else
+ ap_add_version_component("PHP/" PHP_VERSION);
++#endif
+ }
+ }
+ #endif
+diff -Naurp php-5.3.6RC1/sapi/cgi/cgi_main.c php-5.3.6RC1.oden/sapi/cgi/cgi_main.c
+--- php-5.3.6RC1/sapi/cgi/cgi_main.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/sapi/cgi/cgi_main.c 2011-02-20 11:57:02.864596378 +0100
+@@ -1929,10 +1929,18 @@ consult the installation file that came
+ SG(headers_sent) = 1;
+ SG(request_info).no_headers = 1;
+ }
++#if SUHOSIN_PATCH
+ #if ZEND_DEBUG
+- php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2011 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
++ php_printf("PHP %s with Suhosin-Patch (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2011 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
+ #else
+- php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2011 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
++ php_printf("PHP %s with Suhosin-Patch (%s) (built: %s %s)\nCopyright (c) 1997-2011 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
++#endif
++#else
++ #if ZEND_DEBUG
++ php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2011 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
++ #else
++ php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2011 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
++ #endif
+ #endif
+ php_request_shutdown((void *) 0);
+ fcgi_shutdown();
+diff -Naurp php-5.3.6RC1/sapi/cli/php_cli.c php-5.3.6RC1.oden/sapi/cli/php_cli.c
+--- php-5.3.6RC1/sapi/cli/php_cli.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/sapi/cli/php_cli.c 2011-02-20 11:58:39.473179737 +0100
+@@ -832,7 +832,11 @@ int main(int argc, char *argv[])
+ }
+
+ request_started = 1;
+- php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2011 The PHP Group\n%s",
++ php_printf("PHP %s "
++#if SUHOSIN_PATCH
++ "with Suhosin-Patch "
++#endif
++ "(%s) (built: %s %s) %s\nCopyright (c) 1997-2011 The PHP Group\n%s",
+ PHP_VERSION, sapi_module.name, __DATE__, __TIME__,
+ #if ZEND_DEBUG && defined(HAVE_GCOV)
+ "(DEBUG GCOV)",
+diff -Naurp php-5.3.6RC1/Zend/Makefile.am php-5.3.6RC1.oden/Zend/Makefile.am
+--- php-5.3.6RC1/Zend/Makefile.am 2009-03-18 11:18:10.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/Makefile.am 2011-02-20 11:50:19.316838414 +0100
+@@ -17,7 +17,7 @@ libZend_la_SOURCES=\
+ zend_objects_API.c zend_ts_hash.c zend_stream.c \
+ zend_default_classes.c \
+ zend_iterators.c zend_interfaces.c zend_exceptions.c \
+- zend_strtod.c zend_closures.c zend_float.c
++ zend_strtod.c zend_closures.c zend_float.c zend_canary.c zend_alloc_canary.c
+
+ libZend_la_LDFLAGS =
+ libZend_la_LIBADD = @ZEND_EXTRA_LIBS@
+diff -Naurp php-5.3.6RC1/Zend/zend_alloc.c php-5.3.6RC1.oden/Zend/zend_alloc.c
+--- php-5.3.6RC1/Zend/zend_alloc.c 2011-02-07 11:25:34.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/zend_alloc.c 2011-02-20 11:50:19.318838696 +0100
+@@ -32,6 +32,10 @@
+ # include <unistd.h>
+ #endif
+
++#if SUHOSIN_PATCH
++#include "suhosin_patch.h"
++#endif
++
+ #ifdef ZEND_WIN32
+ # include <wincrypt.h>
+ # include <process.h>
+@@ -59,6 +63,7 @@
+ # define PTR_FMT "0x%0.8lx"
+ #endif
+
++#ifndef SUHOSIN_MM_CLONE_FILE
+ #if ZEND_DEBUG
+ void zend_debug_alloc_output(char *format, ...)
+ {
+@@ -76,6 +81,7 @@ void zend_debug_alloc_output(char *forma
+ #endif
+ }
+ #endif
++#endif
+
+ #if (defined (__GNUC__) && __GNUC__ > 2 ) && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX)
+ static void zend_mm_panic(const char *message) __attribute__ ((noreturn));
+@@ -134,6 +140,8 @@ static void zend_mm_panic(const char *me
+ # endif
+ #endif
+
++static zend_intptr_t SUHOSIN_POINTER_GUARD = 0;
++
+ static zend_mm_storage* zend_mm_mem_dummy_init(void *params)
+ {
+ return malloc(sizeof(zend_mm_storage));
+@@ -332,13 +340,28 @@ static const zend_mm_mem_handlers mem_ha
+ #define MEM_BLOCK_GUARD 0x2A8FCC84
+ #define MEM_BLOCK_LEAK 0x6C5E8F2D
+
++#if SUHOSIN_MM_WITH_CANARY_PROTECTION
++# define CANARY_SIZE sizeof(size_t)
++#else
++# define CANARY_SIZE 0
++#endif
++
+ /* mm block type */
+ typedef struct _zend_mm_block_info {
+ #if ZEND_MM_COOKIES
+ size_t _cookie;
+ #endif
+- size_t _size;
+- size_t _prev;
++#if SUHOSIN_MM_WITH_CANARY_PROTECTION
++ size_t canary_1;
++#endif
++ size_t _size;
++ size_t _prev;
++#if SUHOSIN_PATCH
++ size_t size;
++#if SUHOSIN_MM_WITH_CANARY_PROTECTION
++ size_t canary_2;
++#endif
++#endif
+ } zend_mm_block_info;
+
+ #if ZEND_DEBUG
+@@ -412,7 +435,7 @@ typedef struct _zend_mm_free_block {
+ # define ZEND_MM_CACHE_STAT 0
+ #endif
+
+-struct _zend_mm_heap {
++typedef struct _zend_mm_heap {
+ int use_zend_alloc;
+ void *(*_malloc)(size_t);
+ void (*_free)(void*);
+@@ -447,6 +470,9 @@ struct _zend_mm_heap {
+ int miss;
+ } cache_stat[ZEND_MM_NUM_BUCKETS+1];
+ #endif
++#if SUHOSIN_PATCH
++ size_t canary_1,canary_2,canary_3;
++#endif
+ };
+
+ #define ZEND_MM_SMALL_FREE_BUCKET(heap, index) \
+@@ -520,18 +546,31 @@ static unsigned int _zend_mm_cookie = 0;
+ /* optimized access */
+ #define ZEND_MM_FREE_BLOCK_SIZE(b) (b)->info._size
+
++#ifndef ZEND_MM_ALIGNMENT
++# define ZEND_MM_ALIGNMENT 8
++# define ZEND_MM_ALIGNMENT_LOG2 3
++#elif ZEND_MM_ALIGNMENT < 4
++# undef ZEND_MM_ALIGNMENT
++# undef ZEND_MM_ALIGNMENT_LOG2
++# define ZEND_MM_ALIGNMENT 4
++# define ZEND_MM_ALIGNMENT_LOG2 2
++#endif
++
++#define ZEND_MM_ALIGNMENT_MASK ~(ZEND_MM_ALIGNMENT-1)
++
+ /* Aligned header size */
++#define ZEND_MM_ALIGNED_SIZE(size) ((size + ZEND_MM_ALIGNMENT - 1) & ZEND_MM_ALIGNMENT_MASK)
+ #define ZEND_MM_ALIGNED_HEADER_SIZE ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_block))
+ #define ZEND_MM_ALIGNED_FREE_HEADER_SIZE ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_small_free_block))
+-#define ZEND_MM_MIN_ALLOC_BLOCK_SIZE ZEND_MM_ALIGNED_SIZE(ZEND_MM_ALIGNED_HEADER_SIZE + END_MAGIC_SIZE)
++#define ZEND_MM_MIN_ALLOC_BLOCK_SIZE ZEND_MM_ALIGNED_SIZE(ZEND_MM_ALIGNED_HEADER_SIZE + END_MAGIC_SIZE + CANARY_SIZE)
+ #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)
+ #define ZEND_MM_ALIGNED_SEGMENT_SIZE ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_segment))
+
+-#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)
++#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)
+
+ #define ZEND_MM_MAX_SMALL_SIZE ((ZEND_MM_NUM_BUCKETS<<ZEND_MM_ALIGNMENT_LOG2)+ZEND_MM_ALIGNED_MIN_HEADER_SIZE)
+
+-#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)))
++#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)))
+
+ #define ZEND_MM_BUCKET_INDEX(true_size) ((true_size>>ZEND_MM_ALIGNMENT_LOG2)-(ZEND_MM_ALIGNED_MIN_HEADER_SIZE>>ZEND_MM_ALIGNMENT_LOG2))
+
+@@ -593,6 +632,44 @@ static unsigned int _zend_mm_cookie = 0;
+
+ #endif
+
++#if SUHOSIN_MM_WITH_CANARY_PROTECTION
++
++# define SUHOSIN_MM_CHECK_CANARIES(block, MFUNCTION) do { \
++ char *p = SUHOSIN_MM_END_CANARY_PTR(block); size_t check; \
++ if (((block)->info.canary_1 != heap->canary_1) || ((block)->info.canary_2 != heap->canary_2)) { \
++ canary_mismatch: \
++ zend_suhosin_log(S_MEMORY, "canary mismatch on " MFUNCTION " - heap overflow detected at %p", (block)); \
++ if (SUHOSIN_CONFIG(SUHOSIN_MM_IGNORE_CANARY_VIOLATION) == 0) { _exit(1); } else { (block)->info.canary_1 = heap->canary_1; (block)->info.canary_2 = heap->canary_2; }\
++ } \
++ memcpy(&check, p, CANARY_SIZE); \
++ if (check != heap->canary_3) { \
++ zend_suhosin_log(S_MEMORY, "end canary mismatch on " MFUNCTION " - heap overflow detected at %p", (block)); \
++ if (SUHOSIN_CONFIG(SUHOSIN_MM_IGNORE_CANARY_VIOLATION) == 0) { _exit(1); } else { memcpy(p, heap->canary_3, CANARY_SIZE); } \
++ } \
++ } while (0)
++
++# define SUHOSIN_MM_SET_CANARIES(block) do { \
++ (block)->info.canary_1 = heap->canary_1; \
++ (block)->info.canary_2 = heap->canary_2; \
++ } while (0)
++
++# define SUHOSIN_MM_END_CANARY_PTR(block) \
++ (char *)(((char*)(ZEND_MM_DATA_OF(block))) + ((zend_mm_block*)(block))->info.size + END_MAGIC_SIZE)
++
++# define SUHOSIN_MM_SET_END_CANARY(block) do { \
++ char *p = SUHOSIN_MM_END_CANARY_PTR(block); \
++ memcpy(p, &heap->canary_3, CANARY_SIZE); \
++ } while (0)
++
++#else
++
++# define SUHOSIN_MM_CHECK_CANARIES(block, MFUNCTION)
++# define SUHOSIN_MM_SET_CANARIES(block)
++# define SUHOSIN_MM_END_CANARY_PTR(block)
++# define SUHOSIN_MM_SET_END_CANARY(block)
++
++#endif
++
+
+ #if ZEND_MM_HEAP_PROTECTION
+
+@@ -715,7 +792,7 @@ static inline unsigned int zend_mm_low_b
+ #endif
+ }
+
+-static inline void zend_mm_add_to_rest_list(zend_mm_heap *heap, zend_mm_free_block *mm_block)
++static void zend_mm_add_to_rest_list(zend_mm_heap *heap, zend_mm_free_block *mm_block)
+ {
+ zend_mm_free_block *prev, *next;
+
+@@ -725,14 +802,14 @@ static inline void zend_mm_add_to_rest_l
+ mm_block->parent = NULL;
+ }
+
+- prev = heap->rest_buckets[0];
+- next = prev->next_free_block;
+- mm_block->prev_free_block = prev;
+- mm_block->next_free_block = next;
+- prev->next_free_block = next->prev_free_block = mm_block;
++ prev = SUHOSIN_MANGLE_PTR(heap->rest_buckets[0]);
++ next = SUHOSIN_MANGLE_PTR(prev->next_free_block);
++ mm_block->prev_free_block = SUHOSIN_MANGLE_PTR(prev);
++ mm_block->next_free_block = SUHOSIN_MANGLE_PTR(next);
++ prev->next_free_block = next->prev_free_block = SUHOSIN_MANGLE_PTR(mm_block);
+ }
+
+-static inline void zend_mm_add_to_free_list(zend_mm_heap *heap, zend_mm_free_block *mm_block)
++static void zend_mm_add_to_free_list(zend_mm_heap *heap, zend_mm_free_block *mm_block)
+ {
+ size_t size;
+ size_t index;
+@@ -749,7 +826,7 @@ static inline void zend_mm_add_to_free_l
+ if (!*p) {
+ *p = mm_block;
+ mm_block->parent = p;
+- mm_block->prev_free_block = mm_block->next_free_block = mm_block;
++ mm_block->prev_free_block = mm_block->next_free_block = SUHOSIN_MANGLE_PTR(mm_block);
+ heap->large_free_bitmap |= (ZEND_MM_LONG_CONST(1) << index);
+ } else {
+ size_t m;
+@@ -762,15 +839,15 @@ static inline void zend_mm_add_to_free_l
+ if (!*p) {
+ *p = mm_block;
+ mm_block->parent = p;
+- mm_block->prev_free_block = mm_block->next_free_block = mm_block;
++ mm_block->prev_free_block = mm_block->next_free_block = SUHOSIN_MANGLE_PTR(mm_block);
+ break;
+ }
+ } else {
+- zend_mm_free_block *next = prev->next_free_block;
++ zend_mm_free_block *next = SUHOSIN_MANGLE_PTR(prev->next_free_block);
+
+- prev->next_free_block = next->prev_free_block = mm_block;
+- mm_block->next_free_block = next;
+- mm_block->prev_free_block = prev;
++ prev->next_free_block = next->prev_free_block = SUHOSIN_MANGLE_PTR(mm_block);
++ mm_block->next_free_block = SUHOSIN_MANGLE_PTR(next);
++ mm_block->prev_free_block = SUHOSIN_MANGLE_PTR(prev);
+ mm_block->parent = NULL;
+ break;
+ }
+@@ -782,27 +859,33 @@ static inline void zend_mm_add_to_free_l
+ index = ZEND_MM_BUCKET_INDEX(size);
+
+ prev = ZEND_MM_SMALL_FREE_BUCKET(heap, index);
+- if (prev->prev_free_block == prev) {
++ if (SUHOSIN_MANGLE_PTR(prev->prev_free_block) == prev) {
+ heap->free_bitmap |= (ZEND_MM_LONG_CONST(1) << index);
+ }
+- next = prev->next_free_block;
++ next = SUHOSIN_MANGLE_PTR(prev->next_free_block);
+
+- mm_block->prev_free_block = prev;
+- mm_block->next_free_block = next;
+- prev->next_free_block = next->prev_free_block = mm_block;
++ mm_block->prev_free_block = SUHOSIN_MANGLE_PTR(prev);
++ mm_block->next_free_block = SUHOSIN_MANGLE_PTR(next);
++ prev->next_free_block = next->prev_free_block = SUHOSIN_MANGLE_PTR(mm_block);
+ }
+ }
+
+-static inline void zend_mm_remove_from_free_list(zend_mm_heap *heap, zend_mm_free_block *mm_block)
++static void zend_mm_remove_from_free_list(zend_mm_heap *heap, zend_mm_free_block *mm_block)
+ {
+- zend_mm_free_block *prev = mm_block->prev_free_block;
+- zend_mm_free_block *next = mm_block->next_free_block;
++ zend_mm_free_block *prev = SUHOSIN_MANGLE_PTR(mm_block->prev_free_block);
++ zend_mm_free_block *next = SUHOSIN_MANGLE_PTR(mm_block->next_free_block);
+
+ ZEND_MM_CHECK_MAGIC(mm_block, MEM_BLOCK_FREED);
+
+ if (EXPECTED(prev == mm_block)) {
+ zend_mm_free_block **rp, **cp;
+
++#if SUHOSIN_PATCH
++ if (next != mm_block) {
++ zend_suhosin_log(S_MEMORY, "zend_mm_heap corrupted at %p", mm_block);
++ _exit(1);
++ }
++#endif
+ #if ZEND_MM_SAFE_UNLINKING
+ if (UNEXPECTED(next != mm_block)) {
+ zend_mm_panic("zend_mm_heap corrupted");
+@@ -841,14 +924,21 @@ subst_block:
+ }
+ } else {
+
++#if SUHOSIN_PATCH
++ if (SUHOSIN_MANGLE_PTR(prev->next_free_block) != mm_block || SUHOSIN_MANGLE_PTR(next->prev_free_block) != mm_block) {
++ zend_suhosin_log(S_MEMORY, "zend_mm_head corrupted at %p", mm_block);
++ _exit(1);
++ }
++#endif
++
+ #if ZEND_MM_SAFE_UNLINKING
+- if (UNEXPECTED(prev->next_free_block != mm_block) || UNEXPECTED(next->prev_free_block != mm_block)) {
++ if (UNEXPECTED(SUHOSIN_MANGLE_PTR(prev->next_free_block) != mm_block) || UNEXPECTED(SUHOSIN_MANGLE_PTR(next->prev_free_block) != mm_block)) {
+ zend_mm_panic("zend_mm_heap corrupted");
+ }
+ #endif
+
+- prev->next_free_block = next;
+- next->prev_free_block = prev;
++ prev->next_free_block = SUHOSIN_MANGLE_PTR(next);
++ next->prev_free_block = SUHOSIN_MANGLE_PTR(prev);
+
+ if (EXPECTED(ZEND_MM_SMALL_SIZE(ZEND_MM_FREE_BLOCK_SIZE(mm_block)))) {
+ if (EXPECTED(prev == next)) {
+@@ -864,7 +954,7 @@ subst_block:
+ }
+ }
+
+-static inline void zend_mm_init(zend_mm_heap *heap)
++static void zend_mm_init(zend_mm_heap *heap)
+ {
+ zend_mm_free_block* p;
+ int i;
+@@ -882,12 +972,19 @@ static inline void zend_mm_init(zend_mm_
+ #endif
+ p = ZEND_MM_SMALL_FREE_BUCKET(heap, 0);
+ for (i = 0; i < ZEND_MM_NUM_BUCKETS; i++) {
+- p->next_free_block = p;
+- p->prev_free_block = p;
++ p->next_free_block = SUHOSIN_MANGLE_PTR(p);
++ p->prev_free_block = SUHOSIN_MANGLE_PTR(p);
+ p = (zend_mm_free_block*)((char*)p + sizeof(zend_mm_free_block*) * 2);
+ heap->large_free_buckets[i] = NULL;
+ }
+- heap->rest_buckets[0] = heap->rest_buckets[1] = ZEND_MM_REST_BUCKET(heap);
++ heap->rest_buckets[0] = heap->rest_buckets[1] = SUHOSIN_MANGLE_PTR(ZEND_MM_REST_BUCKET(heap));
++#if SUHOSIN_PATCH
++ if (SUHOSIN_CONFIG(SUHOSIN_MM_USE_CANARY_PROTECTION)) {
++ zend_canary(&heap->canary_1, sizeof(heap->canary_1));
++ zend_canary(&heap->canary_2, sizeof(heap->canary_2));
++ zend_canary(&heap->canary_3, sizeof(heap->canary_3));
++ }
++#endif
+ }
+
+ static void zend_mm_del_segment(zend_mm_heap *heap, zend_mm_segment *segment)
+@@ -908,12 +1005,13 @@ static void zend_mm_free_cache(zend_mm_h
+ int i;
+
+ for (i = 0; i < ZEND_MM_NUM_BUCKETS; i++) {
++ /* NULL means NULL even MANGLED */
+ if (heap->cache[i]) {
+- zend_mm_free_block *mm_block = heap->cache[i];
++ zend_mm_free_block *mm_block = SUHOSIN_MANGLE_PTR(heap->cache[i]);
+
+ while (mm_block) {
+ size_t size = ZEND_MM_BLOCK_SIZE(mm_block);
+- zend_mm_free_block *q = mm_block->prev_free_block;
++ zend_mm_free_block *q = SUHOSIN_MANGLE_PTR(mm_block->prev_free_block);
+ zend_mm_block *next_block = ZEND_MM_NEXT_BLOCK(mm_block);
+
+ heap->cached -= size;
+@@ -1009,14 +1107,20 @@ static void zend_mm_random(unsigned char
+ /* }}} */
+ #endif
+
++
+ /* Notes:
+ * - This function may alter the block_sizes values to match platform alignment
+ * - This function does *not* perform sanity checks on the arguments
+ */
+-ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_mem_handlers *handlers, size_t block_size, size_t reserve_size, int internal, void *params)
++#if SUHOSIN_MM_WITH_CANARY_PROTECTION
++zend_mm_heap *__zend_mm_startup_canary_ex(const zend_mm_mem_handlers *handlers, size_t block_size, size_t reserve_size, int internal, void *params)
++#else
++static zend_mm_heap *__zend_mm_startup_ex(const zend_mm_mem_handlers *handlers, size_t block_size, size_t reserve_size, int internal, void *params)
++#endif
+ {
+ zend_mm_storage *storage;
+ zend_mm_heap *heap;
++ zend_mm_free_block *tmp;
+
+ #if 0
+ int i;
+@@ -1050,6 +1154,12 @@ ZEND_API zend_mm_heap *zend_mm_startup_e
+ }
+ #endif
+
++ /* get the pointer guardian and ensure low 3 bits are 1 */
++ if (SUHOSIN_POINTER_GUARD == 0) {
++ zend_canary(&SUHOSIN_POINTER_GUARD, sizeof(SUHOSIN_POINTER_GUARD));
++ SUHOSIN_POINTER_GUARD |= 7;
++ }
++
+ if (zend_mm_low_bit(block_size) != zend_mm_high_bit(block_size)) {
+ fprintf(stderr, "'block_size' must be a power of two\n");
+ /* See http://support.microsoft.com/kb/190351 */
+@@ -1097,12 +1207,12 @@ ZEND_API zend_mm_heap *zend_mm_startup_e
+ heap->reserve = NULL;
+ heap->reserve_size = reserve_size;
+ if (reserve_size > 0) {
+- heap->reserve = _zend_mm_alloc_int(heap, reserve_size ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
++ heap->reserve = _zend_mm_alloc(heap, reserve_size ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
+ }
+ if (internal) {
+ int i;
+ zend_mm_free_block *p, *q, *orig;
+- zend_mm_heap *mm_heap = _zend_mm_alloc_int(heap, sizeof(zend_mm_heap) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
++ zend_mm_heap *mm_heap = _zend_mm_alloc(heap, sizeof(zend_mm_heap) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
+
+ *mm_heap = *heap;
+
+@@ -1110,22 +1220,22 @@ ZEND_API zend_mm_heap *zend_mm_startup_e
+ orig = ZEND_MM_SMALL_FREE_BUCKET(heap, 0);
+ for (i = 0; i < ZEND_MM_NUM_BUCKETS; i++) {
+ q = p;
+- while (q->prev_free_block != orig) {
+- q = q->prev_free_block;
++ while (SUHOSIN_MANGLE_PTR(q->prev_free_block) != orig) {
++ q = SUHOSIN_MANGLE_PTR(q->prev_free_block);
+ }
+- q->prev_free_block = p;
++ q->prev_free_block = SUHOSIN_MANGLE_PTR(p);
+ q = p;
+- while (q->next_free_block != orig) {
+- q = q->next_free_block;
++ while (SUHOSIN_MANGLE_PTR(q->next_free_block) != orig) {
++ q = SUHOSIN_MANGLE_PTR(q->next_free_block);
+ }
+- q->next_free_block = p;
++ q->next_free_block = SUHOSIN_MANGLE_PTR(p);
+ p = (zend_mm_free_block*)((char*)p + sizeof(zend_mm_free_block*) * 2);
+ orig = (zend_mm_free_block*)((char*)orig + sizeof(zend_mm_free_block*) * 2);
+ if (mm_heap->large_free_buckets[i]) {
+ mm_heap->large_free_buckets[i]->parent = &mm_heap->large_free_buckets[i];
+ }
+ }
+- mm_heap->rest_buckets[0] = mm_heap->rest_buckets[1] = ZEND_MM_REST_BUCKET(mm_heap);
++ mm_heap->rest_buckets[0] = mm_heap->rest_buckets[1] = SUHOSIN_MANGLE_PTR(ZEND_MM_REST_BUCKET(mm_heap));
+
+ free(heap);
+ heap = mm_heap;
+@@ -1133,7 +1243,11 @@ ZEND_API zend_mm_heap *zend_mm_startup_e
+ return heap;
+ }
+
+-ZEND_API zend_mm_heap *zend_mm_startup(void)
++#if SUHOSIN_MM_WITH_CANARY_PROTECTION
++zend_mm_heap *__zend_mm_startup_canary(void)
++#else
++static zend_mm_heap *__zend_mm_startup(void)
++#endif
+ {
+ int i;
+ size_t seg_size;
+@@ -1203,6 +1317,27 @@ ZEND_API zend_mm_heap *zend_mm_startup(v
+ return heap;
+ }
+
++#ifndef SUHOSIN_MM_CLONE_FILE
++zend_mm_heap_canary *__zend_mm_startup_canary_ex(const zend_mm_mem_handlers *handlers, size_t block_size, size_t reserve_size, int internal, void *params);
++zend_mm_heap_canary *__zend_mm_startup_canary(void);
++
++ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_mem_handlers *handlers, size_t block_size, size_t reserve_size, int internal, void *params)
++{
++ if (SUHOSIN_CONFIG(SUHOSIN_MM_USE_CANARY_PROTECTION)) {
++ return (zend_mm_heap *)__zend_mm_startup_canary_ex(handlers, block_size, reserve_size, internal, params);
++ }
++ return __zend_mm_startup_ex(handlers, block_size, reserve_size, internal, params);
++}
++ZEND_API zend_mm_heap *zend_mm_startup(void)
++{
++ if (SUHOSIN_CONFIG(SUHOSIN_MM_USE_CANARY_PROTECTION)) {
++ return (zend_mm_heap *)__zend_mm_startup_canary();
++ }
++ return __zend_mm_startup();
++}
++
++#endif
++
+ #if ZEND_DEBUG
+ static long zend_mm_find_leaks(zend_mm_segment *segment, zend_mm_block *b)
+ {
+@@ -1571,7 +1706,11 @@ static int zend_mm_check_heap(zend_mm_he
+ }
+ #endif
+
+-ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, int full_shutdown, int silent TSRMLS_DC)
++#if SUHOSIN_MM_WITH_CANARY_PROTECTION
++void __zend_mm_shutdown_canary(zend_mm_heap *heap, int full_shutdown, int silent TSRMLS_DC)
++#else
++static void __zend_mm_shutdown(zend_mm_heap *heap, int full_shutdown, int silent TSRMLS_DC)
++#endif
+ {
+ zend_mm_storage *storage;
+ zend_mm_segment *segment;
+@@ -1581,7 +1720,7 @@ ZEND_API void zend_mm_shutdown(zend_mm_h
+ if (heap->reserve) {
+ #if ZEND_DEBUG
+ if (!silent) {
+- _zend_mm_free_int(heap, heap->reserve ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
++ _zend_mm_free(heap, heap->reserve ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
+ }
+ #endif
+ heap->reserve = NULL;
+@@ -1664,12 +1803,23 @@ ZEND_API void zend_mm_shutdown(zend_mm_h
+ heap->size = 0;
+ heap->peak = 0;
+ if (heap->reserve_size) {
+- heap->reserve = _zend_mm_alloc_int(heap, heap->reserve_size ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
++ heap->reserve = _zend_mm_alloc(heap, heap->reserve_size ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
+ }
+ heap->overflow = 0;
+ }
+ }
+
++#ifndef SUHOSIN_MM_CLONE_FILE
++ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, int full_shutdown, int silent TSRMLS_DC)
++{
++ if (SUHOSIN_CONFIG(SUHOSIN_MM_USE_CANARY_PROTECTION)) {
++ __zend_mm_shutdown_canary(heap, full_shutdown, silent TSRMLS_CC);
++ return;
++ }
++ __zend_mm_shutdown(heap, full_shutdown, silent TSRMLS_CC);
++}
++#endif
++
+ static void zend_mm_safe_error(zend_mm_heap *heap,
+ const char *format,
+ size_t limit,
+@@ -1680,7 +1830,11 @@ static void zend_mm_safe_error(zend_mm_h
+ size_t size)
+ {
+ if (heap->reserve) {
++#if SUHOSIN_MM_WITH_CANARY_PROTECTION
++ _zend_mm_free_canary_int(heap, heap->reserve ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
++#else
+ _zend_mm_free_int(heap, heap->reserve ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
++#endif
+ heap->reserve = NULL;
+ }
+ if (heap->overflow == 0) {
+@@ -1755,7 +1909,7 @@ static zend_mm_free_block *zend_mm_searc
+ p = heap->large_free_buckets[index];
+ for (m = true_size << (ZEND_MM_NUM_BUCKETS - index); ; m <<= 1) {
+ if (UNEXPECTED(ZEND_MM_FREE_BLOCK_SIZE(p) == true_size)) {
+- return p->next_free_block;
++ return SUHOSIN_MANGLE_PTR(p->next_free_block);
+ } else if (ZEND_MM_FREE_BLOCK_SIZE(p) >= true_size &&
+ ZEND_MM_FREE_BLOCK_SIZE(p) < best_size) {
+ best_size = ZEND_MM_FREE_BLOCK_SIZE(p);
+@@ -1779,7 +1933,7 @@ static zend_mm_free_block *zend_mm_searc
+
+ for (p = rst; p; p = p->child[p->child[0] != NULL]) {
+ if (UNEXPECTED(ZEND_MM_FREE_BLOCK_SIZE(p) == true_size)) {
+- return p->next_free_block;
++ return SUHOSIN_MANGLE_PTR(p->next_free_block);
+ } else if (ZEND_MM_FREE_BLOCK_SIZE(p) > true_size &&
+ ZEND_MM_FREE_BLOCK_SIZE(p) < best_size) {
+ best_size = ZEND_MM_FREE_BLOCK_SIZE(p);
+@@ -1788,7 +1942,7 @@ static zend_mm_free_block *zend_mm_searc
+ }
+
+ if (best_fit) {
+- return best_fit->next_free_block;
++ return SUHOSIN_MANGLE_PTR(best_fit->next_free_block);
+ }
+ bitmap = bitmap >> 1;
+ if (!bitmap) {
+@@ -1804,9 +1958,12 @@ static zend_mm_free_block *zend_mm_searc
+ best_fit = p;
+ }
+ }
+- return best_fit->next_free_block;
++ return SUHOSIN_MANGLE_PTR(best_fit->next_free_block);
+ }
+
++#if SUHOSIN_PATCH
++void *_zend_mm_alloc_canary_int(zend_mm_heap_canary *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
++#endif
+ static void *_zend_mm_alloc_int(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+ {
+ zend_mm_free_block *best_fit;
+@@ -1816,7 +1973,7 @@ static void *_zend_mm_alloc_int(zend_mm_
+ size_t segment_size;
+ zend_mm_segment *segment;
+ int keep_rest = 0;
+-
++
+ if (EXPECTED(ZEND_MM_SMALL_SIZE(true_size))) {
+ size_t index = ZEND_MM_BUCKET_INDEX(true_size);
+ size_t bitmap;
+@@ -1831,9 +1988,14 @@ static void *_zend_mm_alloc_int(zend_mm_
+ heap->cache_stat[index].count--;
+ heap->cache_stat[index].hit++;
+ #endif
+- best_fit = heap->cache[index];
++ best_fit = SUHOSIN_MANGLE_PTR(heap->cache[index]);
+ heap->cache[index] = best_fit->prev_free_block;
+ heap->cached -= true_size;
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_SET_CANARIES(best_fit);
++ ((zend_mm_block*)best_fit)->info.size = size;
++ SUHOSIN_MM_SET_END_CANARY(best_fit);
++#endif
+ ZEND_MM_CHECK_MAGIC(best_fit, MEM_BLOCK_CACHED);
+ ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 0);
+ return ZEND_MM_DATA_OF(best_fit);
+@@ -1847,7 +2009,7 @@ static void *_zend_mm_alloc_int(zend_mm_
+ if (bitmap) {
+ /* Found some "small" free block that can be used */
+ index += zend_mm_low_bit(bitmap);
+- best_fit = heap->free_buckets[index*2];
++ best_fit = SUHOSIN_MANGLE_PTR(heap->free_buckets[index*2]);
+ #if ZEND_MM_CACHE_STAT
+ heap->cache_stat[ZEND_MM_NUM_BUCKETS].hit++;
+ #endif
+@@ -1862,7 +2024,7 @@ static void *_zend_mm_alloc_int(zend_mm_
+ best_fit = zend_mm_search_large_block(heap, true_size);
+
+ if (!best_fit && heap->real_size >= heap->limit - heap->block_size) {
+- zend_mm_free_block *p = heap->rest_buckets[0];
++ zend_mm_free_block *p = SUHOSIN_MANGLE_PTR(heap->rest_buckets[0]);
+ size_t best_size = -1;
+
+ while (p != ZEND_MM_REST_BUCKET(heap)) {
+@@ -1874,7 +2036,7 @@ static void *_zend_mm_alloc_int(zend_mm_
+ best_size = ZEND_MM_FREE_BLOCK_SIZE(p);
+ best_fit = p;
+ }
+- p = p->prev_free_block;
++ p = SUHOSIN_MANGLE_PTR(p->prev_free_block);
+ }
+ }
+
+@@ -1973,13 +2135,19 @@ zend_mm_finished_searching_for_block:
+
+ ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 1);
+
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_SET_CANARIES(best_fit);
++ ((zend_mm_block*)best_fit)->info.size = size;
++ SUHOSIN_MM_SET_END_CANARY(best_fit);
++#endif
++
+ heap->size += true_size;
+ if (heap->peak < heap->size) {
+ heap->peak = heap->size;
+ }
+
+ HANDLE_UNBLOCK_INTERRUPTIONS();
+-
++
+ return ZEND_MM_DATA_OF(best_fit);
+ }
+
+@@ -1996,19 +2164,26 @@ static void _zend_mm_free_int(zend_mm_he
+
+ mm_block = ZEND_MM_HEADER_OF(p);
+ size = ZEND_MM_BLOCK_SIZE(mm_block);
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_CHECK_CANARIES(mm_block, "efree()");
++#endif
+ ZEND_MM_CHECK_PROTECTION(mm_block);
+
+ #if ZEND_DEBUG || ZEND_MM_HEAP_PROTECTION
+ memset(ZEND_MM_DATA_OF(mm_block), 0x5a, mm_block->debug.size);
+ #endif
+-
++#if SUHOSIN_PATCH
++ if (UNEXPECTED(SUHOSIN_CONFIG(SUHOSIN_MM_DESTROY_FREE_MEMORY))) {
++ memset(ZEND_MM_DATA_OF(mm_block), 0x5a, mm_block->info.size);
++ }
++#endif
+ #if ZEND_MM_CACHE
+ if (EXPECTED(ZEND_MM_SMALL_SIZE(size)) && EXPECTED(heap->cached < ZEND_MM_CACHE_SIZE)) {
+ size_t index = ZEND_MM_BUCKET_INDEX(size);
+ zend_mm_free_block **cache = &heap->cache[index];
+
+ ((zend_mm_free_block*)mm_block)->prev_free_block = *cache;
+- *cache = (zend_mm_free_block*)mm_block;
++ *cache = (zend_mm_free_block*)SUHOSIN_MANGLE_PTR(mm_block);
+ heap->cached += size;
+ ZEND_MM_SET_MAGIC(mm_block, MEM_BLOCK_CACHED);
+ #if ZEND_MM_CACHE_STAT
+@@ -2044,6 +2219,9 @@ static void _zend_mm_free_int(zend_mm_he
+ HANDLE_UNBLOCK_INTERRUPTIONS();
+ }
+
++#if SUHOSIN_PATCH
++void *_zend_mm_realloc_canary_int(zend_mm_heap_canary *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
++#endif
+ static void *_zend_mm_realloc_int(zend_mm_heap *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+ {
+ zend_mm_block *mm_block = ZEND_MM_HEADER_OF(p);
+@@ -2053,11 +2231,18 @@ static void *_zend_mm_realloc_int(zend_m
+ void *ptr;
+
+ if (UNEXPECTED(!p) || !ZEND_MM_VALID_PTR(p)) {
++#ifdef SUHOSIN_MM_WITH_CANARY_PROTECTION
++ return _zend_mm_alloc_canary_int(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#else
+ return _zend_mm_alloc_int(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#endif
+ }
+ mm_block = ZEND_MM_HEADER_OF(p);
+ true_size = ZEND_MM_TRUE_SIZE(size);
+ orig_size = ZEND_MM_BLOCK_SIZE(mm_block);
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_CHECK_CANARIES(mm_block, "erealloc()");
++#endif
+ ZEND_MM_CHECK_PROTECTION(mm_block);
+
+ if (UNEXPECTED(true_size < size)) {
+@@ -2089,6 +2274,11 @@ static void *_zend_mm_realloc_int(zend_m
+ HANDLE_UNBLOCK_INTERRUPTIONS();
+ }
+ ZEND_MM_SET_DEBUG_INFO(mm_block, size, 0, 0);
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_SET_CANARIES(mm_block);
++ ((zend_mm_block*)mm_block)->info.size = size;
++ SUHOSIN_MM_SET_END_CANARY(mm_block);
++#endif
+ return p;
+ }
+
+@@ -2104,17 +2294,22 @@ static void *_zend_mm_realloc_int(zend_m
+ heap->cache_stat[index].count--;
+ heap->cache_stat[index].hit++;
+ #endif
+- best_fit = heap->cache[index];
++ best_fit = SUHOSIN_MANGLE_PTR(heap->cache[index]);
+ heap->cache[index] = best_fit->prev_free_block;
+ ZEND_MM_CHECK_MAGIC(best_fit, MEM_BLOCK_CACHED);
+- ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 0);
+-
++ ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 0);
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_SET_CANARIES(best_fit);
++ ((zend_mm_block*)best_fit)->info.size = size;
++ SUHOSIN_MM_SET_END_CANARY(best_fit);
++#endif
++
+ ptr = ZEND_MM_DATA_OF(best_fit);
+
+ #if ZEND_DEBUG || ZEND_MM_HEAP_PROTECTION
+ memcpy(ptr, p, mm_block->debug.size);
+ #else
+- memcpy(ptr, p, orig_size - ZEND_MM_ALIGNED_HEADER_SIZE);
++ memcpy(ptr, p, orig_size - ZEND_MM_ALIGNED_HEADER_SIZE - CANARY_SIZE);
+ #endif
+
+ heap->cached -= true_size - orig_size;
+@@ -2123,14 +2318,13 @@ static void *_zend_mm_realloc_int(zend_m
+ cache = &heap->cache[index];
+
+ ((zend_mm_free_block*)mm_block)->prev_free_block = *cache;
+- *cache = (zend_mm_free_block*)mm_block;
++ *cache = (zend_mm_free_block*)SUHOSIN_MANGLE_PTR(mm_block);
+ ZEND_MM_SET_MAGIC(mm_block, MEM_BLOCK_CACHED);
+ #if ZEND_MM_CACHE_STAT
+ if (++heap->cache_stat[index].count > heap->cache_stat[index].max_count) {
+ heap->cache_stat[index].max_count = heap->cache_stat[index].count;
+ }
+ #endif
+-
+ return ptr;
+ }
+ }
+@@ -2173,6 +2367,11 @@ static void *_zend_mm_realloc_int(zend_m
+ heap->peak = heap->size;
+ }
+ HANDLE_UNBLOCK_INTERRUPTIONS();
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_SET_CANARIES(mm_block);
++ ((zend_mm_block*)mm_block)->info.size = size;
++ SUHOSIN_MM_SET_END_CANARY(mm_block);
++#endif
+ return p;
+ } else if (ZEND_MM_IS_FIRST_BLOCK(mm_block) &&
+ ZEND_MM_IS_GUARD_BLOCK(ZEND_MM_BLOCK_AT(next_block, ZEND_MM_FREE_BLOCK_SIZE(next_block)))) {
+@@ -2275,38 +2474,90 @@ out_of_memory:
+ }
+
+ HANDLE_UNBLOCK_INTERRUPTIONS();
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_SET_CANARIES(mm_block);
++ ((zend_mm_block*)mm_block)->info.size = size;
++ SUHOSIN_MM_SET_END_CANARY(mm_block);
++#endif
+ return ZEND_MM_DATA_OF(mm_block);
+ }
+
++#ifdef SUHOSIN_MM_WITH_CANARY_PROTECTION
++ ptr = _zend_mm_alloc_canary_int(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#else
+ ptr = _zend_mm_alloc_int(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#endif
+ #if ZEND_DEBUG || ZEND_MM_HEAP_PROTECTION
+ memcpy(ptr, p, mm_block->debug.size);
+ #else
+- memcpy(ptr, p, orig_size - ZEND_MM_ALIGNED_HEADER_SIZE);
++ memcpy(ptr, p, orig_size - ZEND_MM_ALIGNED_HEADER_SIZE - CANARY_SIZE);
+ #endif
++#ifdef SUHOSIN_MM_WITH_CANARY_PROTECTION
++ _zend_mm_free_canary_int(heap, p ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#else
+ _zend_mm_free_int(heap, p ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#endif
+ return ptr;
+ }
+
++#ifndef SUHOSIN_MM_CLONE_FILE
+ ZEND_API void *_zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+ {
+- return _zend_mm_alloc_int(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#if SUHOSIN_PATCH
++ if (UNEXPECTED(SUHOSIN_CONFIG(SUHOSIN_MM_USE_CANARY_PROTECTION) == 0))
++#endif
++ return _zend_mm_alloc_int(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#if SUHOSIN_PATCH
++ return _zend_mm_alloc_canary_int((zend_mm_heap_canary *)heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#endif
+ }
+
+ ZEND_API void _zend_mm_free(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+ {
+- _zend_mm_free_int(heap, p ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#if SUHOSIN_PATCH
++ if (UNEXPECTED(SUHOSIN_CONFIG(SUHOSIN_MM_USE_CANARY_PROTECTION) == 0))
++#endif
++ { _zend_mm_free_int(heap, p ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); return; }
++#if SUHOSIN_PATCH
++ _zend_mm_free_canary_int((zend_mm_heap_canary *)heap, p ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#endif
+ }
+
+ ZEND_API void *_zend_mm_realloc(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+ {
+- return _zend_mm_realloc_int(heap, ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#if SUHOSIN_PATCH
++ if (UNEXPECTED(SUHOSIN_CONFIG(SUHOSIN_MM_USE_CANARY_PROTECTION) == 0))
++#endif
++ return _zend_mm_realloc_int(heap, ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#if SUHOSIN_PATCH
++ return _zend_mm_realloc_canary_int((zend_mm_heap_canary *)heap, ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#endif
+ }
+
+ ZEND_API size_t _zend_mm_block_size(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+ {
+ zend_mm_block *mm_block;
+
++ if (SUHOSIN_CONFIG(SUHOSIN_MM_USE_CANARY_PROTECTION) != 0) {
++ return _zend_mm_block_size_canary((zend_mm_heap_canary *)heap, p ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++
++ if (!ZEND_MM_VALID_PTR(p)) {
++ return 0;
++ }
++ mm_block = ZEND_MM_HEADER_OF(p);
++ ZEND_MM_CHECK_PROTECTION(mm_block);
++#if ZEND_DEBUG || ZEND_MM_HEAP_PROTECTION
++ return mm_block->debug.size;
++#else
++ return ZEND_MM_BLOCK_SIZE(mm_block);
++#endif
++}
++#else
++ZEND_API size_t _zend_mm_block_size_canary(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
++{
++ zend_mm_block *mm_block;
++
+ if (!ZEND_MM_VALID_PTR(p)) {
+ return 0;
+ }
+@@ -2319,6 +2570,8 @@ ZEND_API size_t _zend_mm_block_size(zend
+ #endif
+ }
+
++#endif
++
+ /**********************/
+ /* Allocation Manager */
+ /**********************/
+@@ -2335,6 +2588,7 @@ static int alloc_globals_id;
+ static zend_alloc_globals alloc_globals;
+ #endif
+
++#ifndef SUHOSIN_MM_CLONE_FILE
+ ZEND_API int is_zend_mm(TSRMLS_D)
+ {
+ return AG(mm_heap)->use_zend_alloc;
+@@ -2347,7 +2601,13 @@ ZEND_API void *_emalloc(size_t size ZEND
+ if (UNEXPECTED(!AG(mm_heap)->use_zend_alloc)) {
+ return AG(mm_heap)->_malloc(size);
+ }
++#if SUHOSIN_PATCH
++ if (UNEXPECTED(SUHOSIN_CONFIG(SUHOSIN_MM_USE_CANARY_PROTECTION) == 0))
++#endif
+ return _zend_mm_alloc_int(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#if SUHOSIN_PATCH
++ return _zend_mm_alloc_canary_int((zend_mm_heap_canary *)AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#endif
+ }
+
+ ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+@@ -2358,7 +2618,13 @@ ZEND_API void _efree(void *ptr ZEND_FILE
+ AG(mm_heap)->_free(ptr);
+ return;
+ }
+- _zend_mm_free_int(AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#if SUHOSIN_PATCH
++ if (UNEXPECTED(SUHOSIN_CONFIG(SUHOSIN_MM_USE_CANARY_PROTECTION) == 0))
++#endif
++ { _zend_mm_free_int(AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); return; }
++#if SUHOSIN_PATCH
++ _zend_mm_free_canary_int((zend_mm_heap_canary *)AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#endif
+ }
+
+ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+@@ -2368,7 +2634,13 @@ ZEND_API void *_erealloc(void *ptr, size
+ if (UNEXPECTED(!AG(mm_heap)->use_zend_alloc)) {
+ return AG(mm_heap)->_realloc(ptr, size);
+ }
++#if SUHOSIN_PATCH
++ if (UNEXPECTED(SUHOSIN_CONFIG(SUHOSIN_MM_USE_CANARY_PROTECTION) == 0))
++#endif
+ return _zend_mm_realloc_int(AG(mm_heap), ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#if SUHOSIN_PATCH
++ return _zend_mm_realloc_canary_int((zend_mm_heap_canary *)AG(mm_heap), ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#endif
+ }
+
+ ZEND_API size_t _zend_mem_block_size(void *ptr TSRMLS_DC ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+@@ -2376,8 +2648,15 @@ ZEND_API size_t _zend_mem_block_size(voi
+ if (UNEXPECTED(!AG(mm_heap)->use_zend_alloc)) {
+ return 0;
+ }
+- return _zend_mm_block_size(AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#if SUHOSIN_PATCH
++ if (UNEXPECTED(SUHOSIN_CONFIG(SUHOSIN_MM_USE_CANARY_PROTECTION) == 0))
++#endif
++ return _zend_mm_block_size(AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#if SUHOSIN_PATCH
++ return _zend_mm_block_size_canary((zend_mm_heap_canary *)AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#endif
+ }
++#endif
+
+ #if defined(__GNUC__) && defined(i386)
+
+@@ -2448,7 +2727,7 @@ static inline size_t safe_address(size_t
+ }
+ #endif
+
+-
++#ifndef SUHOSIN_MM_CLONE_FILE
+ ZEND_API void *_safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+ {
+ return emalloc_rel(safe_address(nmemb, size, offset));
+@@ -2561,6 +2840,7 @@ ZEND_API void shutdown_memory_manager(in
+ {
+ zend_mm_shutdown(AG(mm_heap), full_shutdown, silent TSRMLS_CC);
+ }
++#endif
+
+ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals TSRMLS_DC)
+ {
+@@ -2585,6 +2865,7 @@ static void alloc_globals_dtor(zend_allo
+ }
+ #endif
+
++#ifndef SUHOSIN_MM_CLONE_FILE
+ ZEND_API void start_memory_manager(TSRMLS_D)
+ {
+ #ifdef ZTS
+@@ -2649,6 +2930,7 @@ ZEND_API void _full_mem_check(int silent
+ zend_debug_alloc_output("------------------------------------------------\n");
+ }
+ #endif
++#endif
+
+ /*
+ * Local variables:
+diff -Naurp php-5.3.6RC1/Zend/zend_alloc_canary.c php-5.3.6RC1.oden/Zend/zend_alloc_canary.c
+--- php-5.3.6RC1/Zend/zend_alloc_canary.c 1970-01-01 01:00:00.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/zend_alloc_canary.c 2011-02-20 11:50:19.320838976 +0100
+@@ -0,0 +1,2498 @@
++/*
++ +----------------------------------------------------------------------+
++ | Suhosin-Patch for PHP |
++ +----------------------------------------------------------------------+
++ | Copyright (c) 2004-2010 Stefan Esser |
++ +----------------------------------------------------------------------+
++ | This source file is subject to version 2.02 of the PHP license, |
++ | that is bundled with this package in the file LICENSE, and is |
++ | available at through the world-wide-web at |
++ | http://www.php.net/license/2_02.txt. |
++ | If you did not receive a copy of the PHP license and are unable to |
++ | obtain it through the world-wide-web, please send a note to |
++ | license@php.net so we can mail you a copy immediately. |
++ +----------------------------------------------------------------------+
++ | Author: Stefan Esser <stefan.esser@sektioneins.de> |
++ +----------------------------------------------------------------------+
++ */
++/* $Id$ */
++
++#include "zend.h"
++#include "zend_alloc.h"
++#include "zend_globals.h"
++#include "zend_operators.h"
++
++#ifdef HAVE_SIGNAL_H
++# include <signal.h>
++#endif
++#ifdef HAVE_UNISTD_H
++# include <unistd.h>
++#endif
++
++#if SUHOSIN_PATCH
++#include "suhosin_patch.h"
++#endif
++
++#ifdef ZEND_WIN32
++# include <wincrypt.h>
++# include <process.h>
++#endif
++
++#ifndef ZEND_MM_HEAP_PROTECTION
++# define ZEND_MM_HEAP_PROTECTION ZEND_DEBUG
++#endif
++
++#ifndef ZEND_MM_SAFE_UNLINKING
++# define ZEND_MM_SAFE_UNLINKING 1
++#endif
++
++#ifndef ZEND_MM_COOKIES
++# define ZEND_MM_COOKIES ZEND_DEBUG
++#endif
++
++#ifdef _WIN64
++# define PTR_FMT "0x%0.16I64x"
++/*
++#elif sizeof(long) == 8
++# define PTR_FMT "0x%0.16lx"
++*/
++#else
++# define PTR_FMT "0x%0.8lx"
++#endif
++
++#define SUHOSIN_MM_WITH_CANARY_PROTECTION 1
++
++#if (defined (__GNUC__) && __GNUC__ > 2 ) && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX)
++static void zend_mm_panic(const char *message) __attribute__ ((noreturn));
++#endif
++
++static void zend_mm_panic(const char *message)
++{
++ fprintf(stderr, "%s\n", message);
++/* See http://support.microsoft.com/kb/190351 */
++#ifdef PHP_WIN32
++ fflush(stderr);
++#endif
++#if ZEND_DEBUG && defined(HAVE_KILL) && defined(HAVE_GETPID)
++ kill(getpid(), SIGSEGV);
++#endif
++ exit(1);
++}
++
++/*******************/
++/* Storage Manager */
++/*******************/
++
++#ifdef ZEND_WIN32
++# define HAVE_MEM_WIN32 /* use VirtualAlloc() to allocate memory */
++#endif
++#define HAVE_MEM_MALLOC /* use malloc() to allocate segments */
++
++#include <sys/types.h>
++#include <sys/stat.h>
++#if HAVE_LIMITS_H
++#include <limits.h>
++#endif
++#include <fcntl.h>
++#include <errno.h>
++
++#if defined(HAVE_MEM_MMAP_ANON) || defined(HAVE_MEM_MMAP_ZERO)
++# ifdef HAVE_MREMAP
++# ifndef _GNU_SOURCE
++# define _GNU_SOURCE
++# endif
++# ifndef __USE_GNU
++# define __USE_GNU
++# endif
++# endif
++# include <sys/mman.h>
++# ifndef MAP_ANON
++# ifdef MAP_ANONYMOUS
++# define MAP_ANON MAP_ANONYMOUS
++# endif
++# endif
++# ifndef MREMAP_MAYMOVE
++# define MREMAP_MAYMOVE 0
++# endif
++# ifndef MAP_FAILED
++# define MAP_FAILED ((void*)-1)
++# endif
++#endif
++
++static zend_intptr_t SUHOSIN_POINTER_GUARD = 0;
++
++static zend_mm_storage* zend_mm_mem_dummy_init(void *params)
++{
++ return malloc(sizeof(zend_mm_storage));
++}
++
++static void zend_mm_mem_dummy_dtor(zend_mm_storage *storage)
++{
++ free(storage);
++}
++
++static void zend_mm_mem_dummy_compact(zend_mm_storage *storage)
++{
++}
++
++#if defined(HAVE_MEM_MMAP_ANON) || defined(HAVE_MEM_MMAP_ZERO)
++
++static zend_mm_segment* zend_mm_mem_mmap_realloc(zend_mm_storage *storage, zend_mm_segment* segment, size_t size)
++{
++ zend_mm_segment *ret;
++#ifdef HAVE_MREMAP
++#if defined(__NetBSD__)
++ /* NetBSD 5 supports mremap but takes an extra newp argument */
++ ret = (zend_mm_segment*)mremap(segment, segment->size, segment, size, MREMAP_MAYMOVE);
++#else
++ ret = (zend_mm_segment*)mremap(segment, segment->size, size, MREMAP_MAYMOVE);
++#endif
++ if (ret == MAP_FAILED) {
++#endif
++ ret = storage->handlers->_alloc(storage, size);
++ if (ret) {
++ memcpy(ret, segment, size > segment->size ? segment->size : size);
++ storage->handlers->_free(storage, segment);
++ }
++#ifdef HAVE_MREMAP
++ }
++#endif
++ return ret;
++}
++
++static void zend_mm_mem_mmap_free(zend_mm_storage *storage, zend_mm_segment* segment)
++{
++ munmap((void*)segment, segment->size);
++}
++
++#endif
++
++#ifdef HAVE_MEM_MMAP_ANON
++
++static zend_mm_segment* zend_mm_mem_mmap_anon_alloc(zend_mm_storage *storage, size_t size)
++{
++ zend_mm_segment *ret = (zend_mm_segment*)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
++ if (ret == MAP_FAILED) {
++ ret = NULL;
++ }
++ return ret;
++}
++
++# define ZEND_MM_MEM_MMAP_ANON_DSC {"mmap_anon", zend_mm_mem_dummy_init, zend_mm_mem_dummy_dtor, zend_mm_mem_dummy_compact, zend_mm_mem_mmap_anon_alloc, zend_mm_mem_mmap_realloc, zend_mm_mem_mmap_free}
++
++#endif
++
++#ifdef HAVE_MEM_MMAP_ZERO
++
++static int zend_mm_dev_zero_fd = -1;
++
++static zend_mm_storage* zend_mm_mem_mmap_zero_init(void *params)
++{
++ if (zend_mm_dev_zero_fd != -1) {
++ zend_mm_dev_zero_fd = open("/dev/zero", O_RDWR, S_IRUSR | S_IWUSR);
++ }
++ if (zend_mm_dev_zero_fd >= 0) {
++ return malloc(sizeof(zend_mm_storage));
++ } else {
++ return NULL;
++ }
++}
++
++static void zend_mm_mem_mmap_zero_dtor(zend_mm_storage *storage)
++{
++ close(zend_mm_dev_zero_fd);
++ free(storage);
++}
++
++static zend_mm_segment* zend_mm_mem_mmap_zero_alloc(zend_mm_storage *storage, size_t size)
++{
++ zend_mm_segment *ret = (zend_mm_segment*)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, zend_mm_dev_zero_fd, 0);
++ if (ret == MAP_FAILED) {
++ ret = NULL;
++ }
++ return ret;
++}
++
++# define ZEND_MM_MEM_MMAP_ZERO_DSC {"mmap_zero", zend_mm_mem_mmap_zero_init, zend_mm_mem_mmap_zero_dtor, zend_mm_mem_dummy_compact, zend_mm_mem_mmap_zero_alloc, zend_mm_mem_mmap_realloc, zend_mm_mem_mmap_free}
++
++#endif
++
++#ifdef HAVE_MEM_WIN32
++
++static zend_mm_storage* zend_mm_mem_win32_init(void *params)
++{
++ HANDLE heap = HeapCreate(HEAP_NO_SERIALIZE, 0, 0);
++ zend_mm_storage* storage;
++
++ if (heap == NULL) {
++ return NULL;
++ }
++ storage = (zend_mm_storage*)malloc(sizeof(zend_mm_storage));
++ storage->data = (void*) heap;
++ return storage;
++}
++
++static void zend_mm_mem_win32_dtor(zend_mm_storage *storage)
++{
++ HeapDestroy((HANDLE)storage->data);
++ free(storage);
++}
++
++static void zend_mm_mem_win32_compact(zend_mm_storage *storage)
++{
++ HeapDestroy((HANDLE)storage->data);
++ storage->data = (void*)HeapCreate(HEAP_NO_SERIALIZE, 0, 0);
++}
++
++static zend_mm_segment* zend_mm_mem_win32_alloc(zend_mm_storage *storage, size_t size)
++{
++ return (zend_mm_segment*) HeapAlloc((HANDLE)storage->data, HEAP_NO_SERIALIZE, size);
++}
++
++static void zend_mm_mem_win32_free(zend_mm_storage *storage, zend_mm_segment* segment)
++{
++ HeapFree((HANDLE)storage->data, HEAP_NO_SERIALIZE, segment);
++}
++
++static zend_mm_segment* zend_mm_mem_win32_realloc(zend_mm_storage *storage, zend_mm_segment* segment, size_t size)
++{
++ return (zend_mm_segment*) HeapReAlloc((HANDLE)storage->data, HEAP_NO_SERIALIZE, segment, size);
++}
++
++# define ZEND_MM_MEM_WIN32_DSC {"win32", zend_mm_mem_win32_init, zend_mm_mem_win32_dtor, zend_mm_mem_win32_compact, zend_mm_mem_win32_alloc, zend_mm_mem_win32_realloc, zend_mm_mem_win32_free}
++
++#endif
++
++#ifdef HAVE_MEM_MALLOC
++
++static zend_mm_segment* zend_mm_mem_malloc_alloc(zend_mm_storage *storage, size_t size)
++{
++ return (zend_mm_segment*)malloc(size);
++}
++
++static zend_mm_segment* zend_mm_mem_malloc_realloc(zend_mm_storage *storage, zend_mm_segment *ptr, size_t size)
++{
++ return (zend_mm_segment*)realloc(ptr, size);
++}
++
++static void zend_mm_mem_malloc_free(zend_mm_storage *storage, zend_mm_segment *ptr)
++{
++ free(ptr);
++}
++
++# define ZEND_MM_MEM_MALLOC_DSC {"malloc", zend_mm_mem_dummy_init, zend_mm_mem_dummy_dtor, zend_mm_mem_dummy_compact, zend_mm_mem_malloc_alloc, zend_mm_mem_malloc_realloc, zend_mm_mem_malloc_free}
++
++#endif
++
++static const zend_mm_mem_handlers mem_handlers[] = {
++#ifdef HAVE_MEM_WIN32
++ ZEND_MM_MEM_WIN32_DSC,
++#endif
++#ifdef HAVE_MEM_MALLOC
++ ZEND_MM_MEM_MALLOC_DSC,
++#endif
++#ifdef HAVE_MEM_MMAP_ANON
++ ZEND_MM_MEM_MMAP_ANON_DSC,
++#endif
++#ifdef HAVE_MEM_MMAP_ZERO
++ ZEND_MM_MEM_MMAP_ZERO_DSC,
++#endif
++ {NULL, NULL, NULL, NULL, NULL, NULL}
++};
++
++# define ZEND_MM_STORAGE_DTOR() heap->storage->handlers->dtor(heap->storage)
++# define ZEND_MM_STORAGE_ALLOC(size) heap->storage->handlers->_alloc(heap->storage, size)
++# define ZEND_MM_STORAGE_REALLOC(ptr, size) heap->storage->handlers->_realloc(heap->storage, ptr, size)
++# define ZEND_MM_STORAGE_FREE(ptr) heap->storage->handlers->_free(heap->storage, ptr)
++
++/****************/
++/* Heap Manager */
++/****************/
++
++#define MEM_BLOCK_VALID 0x7312F8DC
++#define MEM_BLOCK_FREED 0x99954317
++#define MEM_BLOCK_CACHED 0xFB8277DC
++#define MEM_BLOCK_GUARD 0x2A8FCC84
++#define MEM_BLOCK_LEAK 0x6C5E8F2D
++
++#if SUHOSIN_MM_WITH_CANARY_PROTECTION
++# define CANARY_SIZE sizeof(size_t)
++#else
++# define CANARY_SIZE 0
++#endif
++
++/* mm block type */
++typedef struct _zend_mm_block_info_canary {
++#if ZEND_MM_COOKIES
++ size_t _cookie;
++#endif
++#if SUHOSIN_MM_WITH_CANARY_PROTECTION
++ size_t canary_1;
++#endif
++ size_t _size;
++ size_t _prev;
++#if SUHOSIN_PATCH
++ size_t size;
++#if SUHOSIN_MM_WITH_CANARY_PROTECTION
++ size_t canary_2;
++#endif
++#endif
++} zend_mm_block_info_canary;
++
++#if ZEND_DEBUG
++
++typedef struct _zend_mm_debug_info_canary {
++ char *filename;
++ uint lineno;
++ char *orig_filename;
++ uint orig_lineno;
++ size_t size;
++#if ZEND_MM_HEAP_PROTECTION
++ unsigned int start_magic;
++#endif
++} zend_mm_debug_info_canary;
++
++#elif ZEND_MM_HEAP_PROTECTION
++
++typedef struct _zend_mm_debug_info_canary {
++ size_t size;
++ unsigned int start_magic;
++} zend_mm_debug_info_canary;
++
++#endif
++
++typedef struct _zend_mm_block_canary {
++ zend_mm_block_info_canary info;
++#if ZEND_DEBUG
++ unsigned int magic;
++# ifdef ZTS
++ THREAD_T thread_id;
++# endif
++ zend_mm_debug_info_canary debug;
++#elif ZEND_MM_HEAP_PROTECTION
++ zend_mm_debug_info_canary debug;
++#endif
++} zend_mm_block_canary;
++
++typedef struct _zend_mm_small_free_block_canary {
++ zend_mm_block_info_canary info;
++#if ZEND_DEBUG
++ unsigned int magic;
++# ifdef ZTS
++ THREAD_T thread_id;
++# endif
++#endif
++ struct _zend_mm_free_block_canary *prev_free_block;
++ struct _zend_mm_free_block_canary *next_free_block;
++} zend_mm_small_free_block_canary;
++
++typedef struct _zend_mm_free_block_canary {
++ zend_mm_block_info_canary info;
++#if ZEND_DEBUG
++ unsigned int magic;
++# ifdef ZTS
++ THREAD_T thread_id;
++# endif
++#endif
++ struct _zend_mm_free_block_canary *prev_free_block;
++ struct _zend_mm_free_block_canary *next_free_block;
++
++ struct _zend_mm_free_block_canary **parent;
++ struct _zend_mm_free_block_canary *child[2];
++} zend_mm_free_block_canary;
++
++#define ZEND_MM_NUM_BUCKETS (sizeof(size_t) << 3)
++
++#define ZEND_MM_CACHE 1
++#define ZEND_MM_CACHE_SIZE (ZEND_MM_NUM_BUCKETS * 4 * 1024)
++
++#ifndef ZEND_MM_CACHE_STAT
++# define ZEND_MM_CACHE_STAT 0
++#endif
++
++typedef struct _zend_mm_heap_canary {
++ int use_zend_alloc;
++ void *(*_malloc)(size_t);
++ void (*_free)(void*);
++ void *(*_realloc)(void*, size_t);
++ size_t free_bitmap;
++ size_t large_free_bitmap;
++ size_t block_size;
++ size_t compact_size;
++ zend_mm_segment *segments_list;
++ zend_mm_storage *storage;
++ size_t real_size;
++ size_t real_peak;
++ size_t limit;
++ size_t size;
++ size_t peak;
++ size_t reserve_size;
++ void *reserve;
++ int overflow;
++ int internal;
++#if ZEND_MM_CACHE
++ unsigned int cached;
++ zend_mm_free_block_canary *cache[ZEND_MM_NUM_BUCKETS];
++#endif
++ zend_mm_free_block_canary *free_buckets[ZEND_MM_NUM_BUCKETS*2];
++ zend_mm_free_block_canary *large_free_buckets[ZEND_MM_NUM_BUCKETS];
++ zend_mm_free_block_canary *rest_buckets[2];
++#if ZEND_MM_CACHE_STAT
++ struct {
++ int count;
++ int max_count;
++ int hit;
++ int miss;
++ } cache_stat[ZEND_MM_NUM_BUCKETS+1];
++#endif
++#if SUHOSIN_PATCH
++ size_t canary_1,canary_2,canary_3;
++#endif
++};
++
++#define ZEND_MM_SMALL_FREE_BUCKET(heap, index) \
++ (zend_mm_free_block_canary*) ((char*)&heap->free_buckets[index * 2] + \
++ sizeof(zend_mm_free_block_canary*) * 2 - \
++ sizeof(zend_mm_small_free_block_canary))
++
++#define ZEND_MM_REST_BUCKET(heap) \
++ (zend_mm_free_block_canary*)((char*)&heap->rest_buckets[0] + \
++ sizeof(zend_mm_free_block_canary*) * 2 - \
++ sizeof(zend_mm_small_free_block_canary))
++
++#if ZEND_MM_COOKIES
++
++static unsigned int _zend_mm_cookie = 0;
++
++# define ZEND_MM_COOKIE(block) \
++ (((size_t)(block)) ^ _zend_mm_cookie)
++# define ZEND_MM_SET_COOKIE(block) \
++ (block)->info._cookie = ZEND_MM_COOKIE(block)
++# define ZEND_MM_CHECK_COOKIE(block) \
++ if (UNEXPECTED((block)->info._cookie != ZEND_MM_COOKIE(block))) { \
++ zend_mm_panic("zend_mm_heap corrupted"); \
++ }
++#else
++# define ZEND_MM_SET_COOKIE(block)
++# define ZEND_MM_CHECK_COOKIE(block)
++#endif
++
++/* Default memory segment size */
++#define ZEND_MM_SEG_SIZE (256 * 1024)
++
++/* Reserved space for error reporting in case of memory overflow */
++#define ZEND_MM_RESERVE_SIZE (8*1024)
++
++#ifdef _WIN64
++# define ZEND_MM_LONG_CONST(x) (x##i64)
++#else
++# define ZEND_MM_LONG_CONST(x) (x##L)
++#endif
++
++#define ZEND_MM_TYPE_MASK ZEND_MM_LONG_CONST(0x3)
++
++#define ZEND_MM_FREE_BLOCK ZEND_MM_LONG_CONST(0x0)
++#define ZEND_MM_USED_BLOCK ZEND_MM_LONG_CONST(0x1)
++#define ZEND_MM_GUARD_BLOCK ZEND_MM_LONG_CONST(0x3)
++
++#define ZEND_MM_BLOCK(b, type, size) do { \
++ size_t _size = (size); \
++ (b)->info._size = (type) | _size; \
++ ZEND_MM_BLOCK_AT(b, _size)->info._prev = (type) | _size; \
++ ZEND_MM_SET_COOKIE(b); \
++ } while (0);
++#define ZEND_MM_LAST_BLOCK(b) do { \
++ (b)->info._size = ZEND_MM_GUARD_BLOCK | ZEND_MM_ALIGNED_HEADER_SIZE; \
++ ZEND_MM_SET_MAGIC(b, MEM_BLOCK_GUARD); \
++ } while (0);
++#define ZEND_MM_BLOCK_SIZE(b) ((b)->info._size & ~ZEND_MM_TYPE_MASK)
++#define ZEND_MM_IS_FREE_BLOCK(b) (!((b)->info._size & ZEND_MM_USED_BLOCK))
++#define ZEND_MM_IS_USED_BLOCK(b) ((b)->info._size & ZEND_MM_USED_BLOCK)
++#define ZEND_MM_IS_GUARD_BLOCK(b) (((b)->info._size & ZEND_MM_TYPE_MASK) == ZEND_MM_GUARD_BLOCK)
++
++#define ZEND_MM_NEXT_BLOCK(b) ZEND_MM_BLOCK_AT(b, ZEND_MM_BLOCK_SIZE(b))
++#define ZEND_MM_PREV_BLOCK(b) ZEND_MM_BLOCK_AT(b, -(int)((b)->info._prev & ~ZEND_MM_TYPE_MASK))
++
++#define ZEND_MM_PREV_BLOCK_IS_FREE(b) (!((b)->info._prev & ZEND_MM_USED_BLOCK))
++
++#define ZEND_MM_MARK_FIRST_BLOCK(b) ((b)->info._prev = ZEND_MM_GUARD_BLOCK)
++#define ZEND_MM_IS_FIRST_BLOCK(b) ((b)->info._prev == ZEND_MM_GUARD_BLOCK)
++
++/* optimized access */
++#define ZEND_MM_FREE_BLOCK_SIZE(b) (b)->info._size
++
++#ifndef ZEND_MM_ALIGNMENT
++# define ZEND_MM_ALIGNMENT 8
++# define ZEND_MM_ALIGNMENT_LOG2 3
++#elif ZEND_MM_ALIGNMENT < 4
++# undef ZEND_MM_ALIGNMENT
++# undef ZEND_MM_ALIGNMENT_LOG2
++# define ZEND_MM_ALIGNMENT 4
++# define ZEND_MM_ALIGNMENT_LOG2 2
++#endif
++
++#define ZEND_MM_ALIGNMENT_MASK ~(ZEND_MM_ALIGNMENT-1)
++
++/* Aligned header size */
++#define ZEND_MM_ALIGNED_SIZE(size) ((size + ZEND_MM_ALIGNMENT - 1) & ZEND_MM_ALIGNMENT_MASK)
++#define ZEND_MM_ALIGNED_HEADER_SIZE ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_block_canary))
++#define ZEND_MM_ALIGNED_FREE_HEADER_SIZE ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_small_free_block_canary))
++#define ZEND_MM_MIN_ALLOC_BLOCK_SIZE ZEND_MM_ALIGNED_SIZE(ZEND_MM_ALIGNED_HEADER_SIZE + END_MAGIC_SIZE + CANARY_SIZE)
++#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)
++#define ZEND_MM_ALIGNED_SEGMENT_SIZE ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_segment))
++
++#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)
++
++#define ZEND_MM_MAX_SMALL_SIZE ((ZEND_MM_NUM_BUCKETS<<ZEND_MM_ALIGNMENT_LOG2)+ZEND_MM_ALIGNED_MIN_HEADER_SIZE)
++
++#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)))
++
++#define ZEND_MM_BUCKET_INDEX(true_size) ((true_size>>ZEND_MM_ALIGNMENT_LOG2)-(ZEND_MM_ALIGNED_MIN_HEADER_SIZE>>ZEND_MM_ALIGNMENT_LOG2))
++
++#define ZEND_MM_SMALL_SIZE(true_size) (true_size < ZEND_MM_MAX_SMALL_SIZE)
++
++/* Memory calculations */
++#define ZEND_MM_BLOCK_AT(blk, offset) ((zend_mm_block_canary *) (((char *) (blk))+(offset)))
++#define ZEND_MM_DATA_OF(p) ((void *) (((char *) (p))+ZEND_MM_ALIGNED_HEADER_SIZE))
++#define ZEND_MM_HEADER_OF(blk) ZEND_MM_BLOCK_AT(blk, -(int)ZEND_MM_ALIGNED_HEADER_SIZE)
++
++/* Debug output */
++#if ZEND_DEBUG
++
++# ifdef ZTS
++# define ZEND_MM_SET_THREAD_ID(block) \
++ ((zend_mm_block_canary*)(block))->thread_id = tsrm_thread_id()
++# define ZEND_MM_BAD_THREAD_ID(block) ((block)->thread_id != tsrm_thread_id())
++# else
++# define ZEND_MM_SET_THREAD_ID(block)
++# define ZEND_MM_BAD_THREAD_ID(block) 0
++# endif
++
++# define ZEND_MM_VALID_PTR(block) \
++ zend_mm_check_ptr(heap, block, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC)
++
++# define ZEND_MM_SET_MAGIC(block, val) do { \
++ (block)->magic = (val); \
++ } while (0)
++
++# define ZEND_MM_CHECK_MAGIC(block, val) do { \
++ if ((block)->magic != (val)) { \
++ zend_mm_panic("zend_mm_heap corrupted"); \
++ } \
++ } while (0)
++
++# define ZEND_MM_SET_DEBUG_INFO(block, __size, set_valid, set_thread) do { \
++ ((zend_mm_block_canary*)(block))->debug.filename = __zend_filename; \
++ ((zend_mm_block_canary*)(block))->debug.lineno = __zend_lineno; \
++ ((zend_mm_block_canary*)(block))->debug.orig_filename = __zend_orig_filename; \
++ ((zend_mm_block_canary*)(block))->debug.orig_lineno = __zend_orig_lineno; \
++ ZEND_MM_SET_BLOCK_SIZE(block, __size); \
++ if (set_valid) { \
++ ZEND_MM_SET_MAGIC(block, MEM_BLOCK_VALID); \
++ } \
++ if (set_thread) { \
++ ZEND_MM_SET_THREAD_ID(block); \
++ } \
++ } while (0)
++
++#else
++
++# define ZEND_MM_VALID_PTR(ptr) EXPECTED(ptr != NULL)
++
++# define ZEND_MM_SET_MAGIC(block, val)
++
++# define ZEND_MM_CHECK_MAGIC(block, val)
++
++# define ZEND_MM_SET_DEBUG_INFO(block, __size, set_valid, set_thread) ZEND_MM_SET_BLOCK_SIZE(block, __size)
++
++#endif
++
++#if SUHOSIN_MM_WITH_CANARY_PROTECTION
++
++# define SUHOSIN_MM_CHECK_CANARIES(block, MFUNCTION) do { \
++ char *p = SUHOSIN_MM_END_CANARY_PTR(block); size_t check; \
++ if (((block)->info.canary_1 != heap->canary_1) || ((block)->info.canary_2 != heap->canary_2)) { \
++ canary_mismatch: \
++ zend_suhosin_log(S_MEMORY, "canary mismatch on " MFUNCTION " - heap overflow detected at %p", (block)); \
++ if (SUHOSIN_CONFIG(SUHOSIN_MM_IGNORE_CANARY_VIOLATION) == 0) { _exit(1); } else { (block)->info.canary_1 = heap->canary_1; (block)->info.canary_2 = heap->canary_2; }\
++ } \
++ memcpy(&check, p, CANARY_SIZE); \
++ if (check != heap->canary_3) { \
++ zend_suhosin_log(S_MEMORY, "end canary mismatch on " MFUNCTION " - heap overflow detected at %p", (block)); \
++ if (SUHOSIN_CONFIG(SUHOSIN_MM_IGNORE_CANARY_VIOLATION) == 0) { _exit(1); } else { memcpy(p, heap->canary_3, CANARY_SIZE); } \
++ } \
++ } while (0)
++
++# define SUHOSIN_MM_SET_CANARIES(block) do { \
++ (block)->info.canary_1 = heap->canary_1; \
++ (block)->info.canary_2 = heap->canary_2; \
++ } while (0)
++
++# define SUHOSIN_MM_END_CANARY_PTR(block) \
++ (char *)(((char*)(ZEND_MM_DATA_OF(block))) + ((zend_mm_block_canary*)(block))->info.size + END_MAGIC_SIZE)
++
++# define SUHOSIN_MM_SET_END_CANARY(block) do { \
++ char *p = SUHOSIN_MM_END_CANARY_PTR(block); \
++ memcpy(p, &heap->canary_3, CANARY_SIZE); \
++ } while (0)
++
++#else
++
++# define SUHOSIN_MM_CHECK_CANARIES(block, MFUNCTION)
++# define SUHOSIN_MM_SET_CANARIES(block)
++# define SUHOSIN_MM_END_CANARY_PTR(block)
++# define SUHOSIN_MM_SET_END_CANARY(block)
++
++#endif
++
++
++#if ZEND_MM_HEAP_PROTECTION
++
++# define ZEND_MM_CHECK_PROTECTION(block) \
++ do { \
++ if ((block)->debug.start_magic != _mem_block_start_magic || \
++ memcmp(ZEND_MM_END_MAGIC_PTR(block), &_mem_block_end_magic, END_MAGIC_SIZE) != 0) { \
++ zend_mm_panic("zend_mm_heap corrupted"); \
++ } \
++ } while (0)
++
++# define ZEND_MM_END_MAGIC_PTR(block) \
++ (((char*)(ZEND_MM_DATA_OF(block))) + ((zend_mm_block_canary*)(block))->debug.size)
++
++# define END_MAGIC_SIZE sizeof(unsigned int)
++
++# define ZEND_MM_SET_BLOCK_SIZE(block, __size) do { \
++ char *p; \
++ ((zend_mm_block_canary*)(block))->debug.size = (__size); \
++ p = ZEND_MM_END_MAGIC_PTR(block); \
++ ((zend_mm_block_canary*)(block))->debug.start_magic = _mem_block_start_magic; \
++ memcpy(p, &_mem_block_end_magic, END_MAGIC_SIZE); \
++ } while (0)
++
++static unsigned int _mem_block_start_magic = 0;
++static unsigned int _mem_block_end_magic = 0;
++
++#else
++
++# if ZEND_DEBUG
++# define ZEND_MM_SET_BLOCK_SIZE(block, _size) \
++ ((zend_mm_block_canary*)(block))->debug.size = (_size)
++# else
++# define ZEND_MM_SET_BLOCK_SIZE(block, _size)
++# endif
++
++# define ZEND_MM_CHECK_PROTECTION(block)
++
++# define END_MAGIC_SIZE 0
++
++#endif
++
++#if ZEND_MM_SAFE_UNLINKING
++# define ZEND_MM_CHECK_BLOCK_LINKAGE(block) \
++ if (UNEXPECTED((block)->info._size != ZEND_MM_BLOCK_AT(block, ZEND_MM_FREE_BLOCK_SIZE(block))->info._prev) || \
++ UNEXPECTED(!UNEXPECTED(ZEND_MM_IS_FIRST_BLOCK(block)) && \
++ UNEXPECTED(ZEND_MM_PREV_BLOCK(block)->info._size != (block)->info._prev))) { \
++ zend_mm_panic("zend_mm_heap corrupted"); \
++ }
++#define ZEND_MM_CHECK_TREE(block) \
++ if (UNEXPECTED(*((block)->parent) != (block))) { \
++ zend_mm_panic("zend_mm_heap corrupted"); \
++ }
++#else
++# define ZEND_MM_CHECK_BLOCK_LINKAGE(block)
++# define ZEND_MM_CHECK_TREE(block)
++#endif
++
++#define ZEND_MM_LARGE_BUCKET_INDEX(S) zend_mm_high_bit(S)
++
++void *_zend_mm_alloc_canary_int(zend_mm_heap_canary *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
++void _zend_mm_free_canary_int(zend_mm_heap_canary *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
++void *_zend_mm_realloc_canary_int(zend_mm_heap_canary *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
++
++
++static inline unsigned int zend_mm_high_bit(size_t _size)
++{
++#if defined(__GNUC__) && defined(i386)
++ unsigned int n;
++
++ __asm__("bsrl %1,%0\n\t" : "=r" (n) : "rm" (_size));
++ return n;
++#elif defined(__GNUC__) && defined(__x86_64__)
++ unsigned long n;
++
++ __asm__("bsrq %1,%0\n\t" : "=r" (n) : "rm" (_size));
++ return (unsigned int)n;
++#elif defined(_MSC_VER) && defined(_M_IX86)
++ __asm {
++ bsr eax, _size
++ }
++#else
++ unsigned int n = 0;
++ while (_size != 0) {
++ _size = _size >> 1;
++ n++;
++ }
++ return n-1;
++#endif
++}
++
++static inline unsigned int zend_mm_low_bit(size_t _size)
++{
++#if defined(__GNUC__) && defined(i386)
++ unsigned int n;
++
++ __asm__("bsfl %1,%0\n\t" : "=r" (n) : "rm" (_size));
++ return n;
++#elif defined(__GNUC__) && defined(__x86_64__)
++ unsigned long n;
++
++ __asm__("bsfq %1,%0\n\t" : "=r" (n) : "rm" (_size));
++ return (unsigned int)n;
++#elif defined(_MSC_VER) && defined(_M_IX86)
++ __asm {
++ bsf eax, _size
++ }
++#else
++ static const int offset[16] = {4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0};
++ unsigned int n;
++ unsigned int index = 0;
++
++ n = offset[_size & 15];
++ while (n == 4) {
++ _size >>= 4;
++ index += n;
++ n = offset[_size & 15];
++ }
++
++ return index + n;
++#endif
++}
++
++static void zend_mm_add_to_rest_list(zend_mm_heap_canary *heap, zend_mm_free_block_canary *mm_block)
++{
++ zend_mm_free_block_canary *prev, *next;
++
++ ZEND_MM_SET_MAGIC(mm_block, MEM_BLOCK_FREED);
++
++ if (!ZEND_MM_SMALL_SIZE(ZEND_MM_FREE_BLOCK_SIZE(mm_block))) {
++ mm_block->parent = NULL;
++ }
++
++ prev = SUHOSIN_MANGLE_PTR(heap->rest_buckets[0]);
++ next = SUHOSIN_MANGLE_PTR(prev->next_free_block);
++ mm_block->prev_free_block = SUHOSIN_MANGLE_PTR(prev);
++ mm_block->next_free_block = SUHOSIN_MANGLE_PTR(next);
++ prev->next_free_block = next->prev_free_block = SUHOSIN_MANGLE_PTR(mm_block);
++}
++
++static void zend_mm_add_to_free_list(zend_mm_heap_canary *heap, zend_mm_free_block_canary *mm_block)
++{
++ size_t size;
++ size_t index;
++
++ ZEND_MM_SET_MAGIC(mm_block, MEM_BLOCK_FREED);
++
++ size = ZEND_MM_FREE_BLOCK_SIZE(mm_block);
++ if (EXPECTED(!ZEND_MM_SMALL_SIZE(size))) {
++ zend_mm_free_block_canary **p;
++
++ index = ZEND_MM_LARGE_BUCKET_INDEX(size);
++ p = &heap->large_free_buckets[index];
++ mm_block->child[0] = mm_block->child[1] = NULL;
++ if (!*p) {
++ *p = mm_block;
++ mm_block->parent = p;
++ mm_block->prev_free_block = mm_block->next_free_block = SUHOSIN_MANGLE_PTR(mm_block);
++ heap->large_free_bitmap |= (ZEND_MM_LONG_CONST(1) << index);
++ } else {
++ size_t m;
++
++ for (m = size << (ZEND_MM_NUM_BUCKETS - index); ; m <<= 1) {
++ zend_mm_free_block_canary *prev = *p;
++
++ if (ZEND_MM_FREE_BLOCK_SIZE(prev) != size) {
++ p = &prev->child[(m >> (ZEND_MM_NUM_BUCKETS-1)) & 1];
++ if (!*p) {
++ *p = mm_block;
++ mm_block->parent = p;
++ mm_block->prev_free_block = mm_block->next_free_block = SUHOSIN_MANGLE_PTR(mm_block);
++ break;
++ }
++ } else {
++ zend_mm_free_block_canary *next = SUHOSIN_MANGLE_PTR(prev->next_free_block);
++
++ prev->next_free_block = next->prev_free_block = SUHOSIN_MANGLE_PTR(mm_block);
++ mm_block->next_free_block = SUHOSIN_MANGLE_PTR(next);
++ mm_block->prev_free_block = SUHOSIN_MANGLE_PTR(prev);
++ mm_block->parent = NULL;
++ break;
++ }
++ }
++ }
++ } else {
++ zend_mm_free_block_canary *prev, *next;
++
++ index = ZEND_MM_BUCKET_INDEX(size);
++
++ prev = ZEND_MM_SMALL_FREE_BUCKET(heap, index);
++ if (SUHOSIN_MANGLE_PTR(prev->prev_free_block) == prev) {
++ heap->free_bitmap |= (ZEND_MM_LONG_CONST(1) << index);
++ }
++ next = SUHOSIN_MANGLE_PTR(prev->next_free_block);
++
++ mm_block->prev_free_block = SUHOSIN_MANGLE_PTR(prev);
++ mm_block->next_free_block = SUHOSIN_MANGLE_PTR(next);
++ prev->next_free_block = next->prev_free_block = SUHOSIN_MANGLE_PTR(mm_block);
++ }
++}
++
++static void zend_mm_remove_from_free_list(zend_mm_heap_canary *heap, zend_mm_free_block_canary *mm_block)
++{
++ zend_mm_free_block_canary *prev = SUHOSIN_MANGLE_PTR(mm_block->prev_free_block);
++ zend_mm_free_block_canary *next = SUHOSIN_MANGLE_PTR(mm_block->next_free_block);
++
++ ZEND_MM_CHECK_MAGIC(mm_block, MEM_BLOCK_FREED);
++
++ if (EXPECTED(prev == mm_block)) {
++ zend_mm_free_block_canary **rp, **cp;
++
++#if SUHOSIN_PATCH
++ if (next != mm_block) {
++ zend_suhosin_log(S_MEMORY, "zend_mm_heap corrupted at %p", mm_block);
++ _exit(1);
++ }
++#endif
++#if ZEND_MM_SAFE_UNLINKING
++ if (UNEXPECTED(next != mm_block)) {
++ zend_mm_panic("zend_mm_heap corrupted");
++ }
++#endif
++
++ rp = &mm_block->child[mm_block->child[1] != NULL];
++ prev = *rp;
++ if (EXPECTED(prev == NULL)) {
++ size_t index = ZEND_MM_LARGE_BUCKET_INDEX(ZEND_MM_FREE_BLOCK_SIZE(mm_block));
++
++ ZEND_MM_CHECK_TREE(mm_block);
++ *mm_block->parent = NULL;
++ if (mm_block->parent == &heap->large_free_buckets[index]) {
++ heap->large_free_bitmap &= ~(ZEND_MM_LONG_CONST(1) << index);
++ }
++ } else {
++ while (*(cp = &(prev->child[prev->child[1] != NULL])) != NULL) {
++ prev = *cp;
++ rp = cp;
++ }
++ *rp = NULL;
++
++subst_block:
++ ZEND_MM_CHECK_TREE(mm_block);
++ *mm_block->parent = prev;
++ prev->parent = mm_block->parent;
++ if ((prev->child[0] = mm_block->child[0])) {
++ ZEND_MM_CHECK_TREE(prev->child[0]);
++ prev->child[0]->parent = &prev->child[0];
++ }
++ if ((prev->child[1] = mm_block->child[1])) {
++ ZEND_MM_CHECK_TREE(prev->child[1]);
++ prev->child[1]->parent = &prev->child[1];
++ }
++ }
++ } else {
++
++#if SUHOSIN_PATCH
++ if (SUHOSIN_MANGLE_PTR(prev->next_free_block) != mm_block || SUHOSIN_MANGLE_PTR(next->prev_free_block) != mm_block) {
++ zend_suhosin_log(S_MEMORY, "zend_mm_head corrupted at %p", mm_block);
++ _exit(1);
++ }
++#endif
++
++#if ZEND_MM_SAFE_UNLINKING
++ if (UNEXPECTED(SUHOSIN_MANGLE_PTR(prev->next_free_block) != mm_block) || UNEXPECTED(SUHOSIN_MANGLE_PTR(next->prev_free_block) != mm_block)) {
++ zend_mm_panic("zend_mm_heap corrupted");
++ }
++#endif
++
++ prev->next_free_block = SUHOSIN_MANGLE_PTR(next);
++ next->prev_free_block = SUHOSIN_MANGLE_PTR(prev);
++
++ if (EXPECTED(ZEND_MM_SMALL_SIZE(ZEND_MM_FREE_BLOCK_SIZE(mm_block)))) {
++ if (EXPECTED(prev == next)) {
++ size_t index = ZEND_MM_BUCKET_INDEX(ZEND_MM_FREE_BLOCK_SIZE(mm_block));
++
++ if (EXPECTED(heap->free_buckets[index*2] == heap->free_buckets[index*2+1])) {
++ heap->free_bitmap &= ~(ZEND_MM_LONG_CONST(1) << index);
++ }
++ }
++ } else if (UNEXPECTED(mm_block->parent != NULL)) {
++ goto subst_block;
++ }
++ }
++}
++
++static void zend_mm_init(zend_mm_heap_canary *heap)
++{
++ zend_mm_free_block_canary* p;
++ int i;
++
++ heap->free_bitmap = 0;
++ heap->large_free_bitmap = 0;
++#if ZEND_MM_CACHE
++ heap->cached = 0;
++ memset(heap->cache, 0, sizeof(heap->cache));
++#endif
++#if ZEND_MM_CACHE_STAT
++ for (i = 0; i < ZEND_MM_NUM_BUCKETS; i++) {
++ heap->cache_stat[i].count = 0;
++ }
++#endif
++ p = ZEND_MM_SMALL_FREE_BUCKET(heap, 0);
++ for (i = 0; i < ZEND_MM_NUM_BUCKETS; i++) {
++ p->next_free_block = SUHOSIN_MANGLE_PTR(p);
++ p->prev_free_block = SUHOSIN_MANGLE_PTR(p);
++ p = (zend_mm_free_block_canary*)((char*)p + sizeof(zend_mm_free_block_canary*) * 2);
++ heap->large_free_buckets[i] = NULL;
++ }
++ heap->rest_buckets[0] = heap->rest_buckets[1] = SUHOSIN_MANGLE_PTR(ZEND_MM_REST_BUCKET(heap));
++#if SUHOSIN_PATCH
++ if (SUHOSIN_CONFIG(SUHOSIN_MM_USE_CANARY_PROTECTION)) {
++ zend_canary(&heap->canary_1, sizeof(heap->canary_1));
++ zend_canary(&heap->canary_2, sizeof(heap->canary_2));
++ zend_canary(&heap->canary_3, sizeof(heap->canary_3));
++ }
++#endif
++}
++
++static void zend_mm_del_segment(zend_mm_heap_canary *heap, zend_mm_segment *segment)
++{
++ zend_mm_segment **p = &heap->segments_list;
++
++ while (*p != segment) {
++ p = &(*p)->next_segment;
++ }
++ *p = segment->next_segment;
++ heap->real_size -= segment->size;
++ ZEND_MM_STORAGE_FREE(segment);
++}
++
++#if ZEND_MM_CACHE
++static void zend_mm_free_cache(zend_mm_heap_canary *heap)
++{
++ int i;
++
++ for (i = 0; i < ZEND_MM_NUM_BUCKETS; i++) {
++ /* SUHOSIN_MANGLE_PTR should NOT affect NULL pointers */
++ if (heap->cache[i]) {
++ zend_mm_free_block_canary *mm_block = SUHOSIN_MANGLE_PTR(heap->cache[i]);
++
++ while (mm_block) {
++ size_t size = ZEND_MM_BLOCK_SIZE(mm_block);
++ zend_mm_free_block_canary *q = SUHOSIN_MANGLE_PTR(mm_block->prev_free_block);
++ zend_mm_block_canary *next_block = ZEND_MM_NEXT_BLOCK(mm_block);
++
++ heap->cached -= size;
++
++ if (ZEND_MM_PREV_BLOCK_IS_FREE(mm_block)) {
++ mm_block = (zend_mm_free_block_canary*)ZEND_MM_PREV_BLOCK(mm_block);
++ size += ZEND_MM_FREE_BLOCK_SIZE(mm_block);
++ zend_mm_remove_from_free_list(heap, (zend_mm_free_block_canary *) mm_block);
++ }
++ if (ZEND_MM_IS_FREE_BLOCK(next_block)) {
++ size += ZEND_MM_FREE_BLOCK_SIZE(next_block);
++ zend_mm_remove_from_free_list(heap, (zend_mm_free_block_canary *) next_block);
++ }
++ ZEND_MM_BLOCK(mm_block, ZEND_MM_FREE_BLOCK, size);
++
++ if (ZEND_MM_IS_FIRST_BLOCK(mm_block) &&
++ ZEND_MM_IS_GUARD_BLOCK(ZEND_MM_NEXT_BLOCK(mm_block))) {
++ zend_mm_del_segment(heap, (zend_mm_segment *) ((char *)mm_block - ZEND_MM_ALIGNED_SEGMENT_SIZE));
++ } else {
++ zend_mm_add_to_free_list(heap, (zend_mm_free_block_canary *) mm_block);
++ }
++
++ mm_block = q;
++ }
++ heap->cache[i] = NULL;
++#if ZEND_MM_CACHE_STAT
++ heap->cache_stat[i].count = 0;
++#endif
++ }
++ }
++}
++#endif
++
++#if ZEND_MM_HEAP_PROTECTION || ZEND_MM_COOKIES
++static void zend_mm_random(unsigned char *buf, size_t size) /* {{{ */
++{
++ size_t i = 0;
++ unsigned char t;
++
++#ifdef ZEND_WIN32
++ HCRYPTPROV hCryptProv;
++ int has_context = 0;
++
++ if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)) {
++ /* Could mean that the key container does not exist, let try
++ again by asking for a new one */
++ if (GetLastError() == NTE_BAD_KEYSET) {
++ if (CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET)) {
++ has_context = 1;
++ }
++ }
++ } else {
++ has_context = 1;
++ }
++ if (has_context) {
++ do {
++ BOOL ret = CryptGenRandom(hCryptProv, size, buf);
++ CryptReleaseContext(hCryptProv, 0);
++ if (ret) {
++ while (i < size && buf[i] != 0) {
++ i++;
++ }
++ if (i == size) {
++ return;
++ }
++ }
++ } while (0);
++ }
++#elif defined(HAVE_DEV_URANDOM)
++ int fd = open("/dev/urandom", 0);
++
++ if (fd >= 0) {
++ if (read(fd, buf, size) == size) {
++ while (i < size && buf[i] != 0) {
++ i++;
++ }
++ if (i == size) {
++ close(fd);
++ return;
++ }
++ }
++ close(fd);
++ }
++#endif
++ t = (unsigned char)getpid();
++ while (i < size) {
++ do {
++ buf[i] = ((unsigned char)rand()) ^ t;
++ } while (buf[i] == 0);
++ t = buf[i++] << 1;
++ }
++}
++/* }}} */
++#endif
++
++
++/* Notes:
++ * - This function may alter the block_sizes values to match platform alignment
++ * - This function does *not* perform sanity checks on the arguments
++ */
++zend_mm_heap_canary *__zend_mm_startup_canary_ex(const zend_mm_mem_handlers *handlers, size_t block_size, size_t reserve_size, int internal, void *params)
++{
++ zend_mm_storage *storage;
++ zend_mm_heap_canary *heap;
++ zend_mm_free_block_canary *tmp;
++
++#if 0
++ int i;
++
++ printf("ZEND_MM_ALIGNMENT=%d\n", ZEND_MM_ALIGNMENT);
++ printf("ZEND_MM_ALIGNMENT_LOG2=%d\n", ZEND_MM_ALIGNMENT_LOG2);
++ printf("ZEND_MM_MIN_SIZE=%d\n", ZEND_MM_MIN_SIZE);
++ printf("ZEND_MM_MAX_SMALL_SIZE=%d\n", ZEND_MM_MAX_SMALL_SIZE);
++ printf("ZEND_MM_ALIGNED_HEADER_SIZE=%d\n", ZEND_MM_ALIGNED_HEADER_SIZE);
++ printf("ZEND_MM_ALIGNED_FREE_HEADER_SIZE=%d\n", ZEND_MM_ALIGNED_FREE_HEADER_SIZE);
++ printf("ZEND_MM_MIN_ALLOC_BLOCK_SIZE=%d\n", ZEND_MM_MIN_ALLOC_BLOCK_SIZE);
++ printf("ZEND_MM_ALIGNED_MIN_HEADER_SIZE=%d\n", ZEND_MM_ALIGNED_MIN_HEADER_SIZE);
++ printf("ZEND_MM_ALIGNED_SEGMENT_SIZE=%d\n", ZEND_MM_ALIGNED_SEGMENT_SIZE);
++ for (i = 0; i < ZEND_MM_MAX_SMALL_SIZE; i++) {
++ printf("%3d%c: %3ld %d %2ld\n", i, (i == ZEND_MM_MIN_SIZE?'*':' '), (long)ZEND_MM_TRUE_SIZE(i), ZEND_MM_SMALL_SIZE(ZEND_MM_TRUE_SIZE(i)), (long)ZEND_MM_BUCKET_INDEX(ZEND_MM_TRUE_SIZE(i)));
++ }
++ exit(0);
++#endif
++
++#if ZEND_MM_HEAP_PROTECTION
++ if (_mem_block_start_magic == 0) {
++ zend_mm_random((unsigned char*)&_mem_block_start_magic, sizeof(_mem_block_start_magic));
++ }
++ if (_mem_block_end_magic == 0) {
++ zend_mm_random((unsigned char*)&_mem_block_end_magic, sizeof(_mem_block_end_magic));
++ }
++#endif
++#if ZEND_MM_COOKIES
++ if (_zend_mm_cookie == 0) {
++ zend_mm_random((unsigned char*)&_zend_mm_cookie, sizeof(_zend_mm_cookie));
++ }
++#endif
++
++ /* get the pointer guardian and ensure low 3 bits are 1 */
++ if (SUHOSIN_POINTER_GUARD == 0) {
++ zend_canary(&SUHOSIN_POINTER_GUARD, sizeof(SUHOSIN_POINTER_GUARD));
++ SUHOSIN_POINTER_GUARD |= 7;
++ }
++
++ if (zend_mm_low_bit(block_size) != zend_mm_high_bit(block_size)) {
++ fprintf(stderr, "'block_size' must be a power of two\n");
++/* See http://support.microsoft.com/kb/190351 */
++#ifdef PHP_WIN32
++ fflush(stderr);
++#endif
++ exit(255);
++ }
++ storage = handlers->init(params);
++ if (!storage) {
++ fprintf(stderr, "Cannot initialize zend_mm storage [%s]\n", handlers->name);
++/* See http://support.microsoft.com/kb/190351 */
++#ifdef PHP_WIN32
++ fflush(stderr);
++#endif
++ exit(255);
++ }
++ storage->handlers = handlers;
++
++ heap = malloc(sizeof(struct _zend_mm_heap_canary));
++
++ heap->storage = storage;
++ heap->block_size = block_size;
++ heap->compact_size = 0;
++ heap->segments_list = NULL;
++ zend_mm_init(heap);
++# if ZEND_MM_CACHE_STAT
++ memset(heap->cache_stat, 0, sizeof(heap->cache_stat));
++# endif
++
++ heap->use_zend_alloc = 1;
++ heap->real_size = 0;
++ heap->overflow = 0;
++ heap->real_peak = 0;
++ heap->limit = ZEND_MM_LONG_CONST(1)<<(ZEND_MM_NUM_BUCKETS-2);
++ heap->size = 0;
++ heap->peak = 0;
++ heap->internal = internal;
++ heap->reserve = NULL;
++ heap->reserve_size = reserve_size;
++ if (reserve_size > 0) {
++ heap->reserve = _zend_mm_alloc((zend_mm_heap *)heap, reserve_size ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
++ }
++ if (internal) {
++ int i;
++ zend_mm_free_block_canary *p, *q, *orig;
++ zend_mm_heap_canary *mm_heap = _zend_mm_alloc((zend_mm_heap *)heap, sizeof(zend_mm_heap_canary) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
++
++ *mm_heap = *heap;
++
++ p = ZEND_MM_SMALL_FREE_BUCKET(mm_heap, 0);
++ orig = ZEND_MM_SMALL_FREE_BUCKET(heap, 0);
++ for (i = 0; i < ZEND_MM_NUM_BUCKETS; i++) {
++ q = p;
++ while (SUHOSIN_MANGLE_PTR(q->prev_free_block) != orig) {
++ q = SUHOSIN_MANGLE_PTR(q->prev_free_block);
++ }
++ q->prev_free_block = SUHOSIN_MANGLE_PTR(p);
++ q = p;
++ while (SUHOSIN_MANGLE_PTR(q->next_free_block) != orig) {
++ q = SUHOSIN_MANGLE_PTR(q->next_free_block);
++ }
++ q->next_free_block = SUHOSIN_MANGLE_PTR(p);
++ p = (zend_mm_free_block_canary*)((char*)p + sizeof(zend_mm_free_block_canary*) * 2);
++ orig = (zend_mm_free_block_canary*)((char*)orig + sizeof(zend_mm_free_block_canary*) * 2);
++ if (mm_heap->large_free_buckets[i]) {
++ mm_heap->large_free_buckets[i]->parent = &mm_heap->large_free_buckets[i];
++ }
++ }
++ mm_heap->rest_buckets[0] = mm_heap->rest_buckets[1] = SUHOSIN_MANGLE_PTR(ZEND_MM_REST_BUCKET(mm_heap));
++
++ free(heap);
++ heap = mm_heap;
++ }
++ return heap;
++}
++
++zend_mm_heap_canary *__zend_mm_startup_canary(void)
++{
++ int i;
++ size_t seg_size;
++ char *mem_type = getenv("ZEND_MM_MEM_TYPE");
++ char *tmp;
++ const zend_mm_mem_handlers *handlers;
++ zend_mm_heap_canary *heap;
++
++ if (mem_type == NULL) {
++ i = 0;
++ } else {
++ for (i = 0; mem_handlers[i].name; i++) {
++ if (strcmp(mem_handlers[i].name, mem_type) == 0) {
++ break;
++ }
++ }
++ if (!mem_handlers[i].name) {
++ fprintf(stderr, "Wrong or unsupported zend_mm storage type '%s'\n", mem_type);
++ fprintf(stderr, " supported types:\n");
++/* See http://support.microsoft.com/kb/190351 */
++#ifdef PHP_WIN32
++ fflush(stderr);
++#endif
++ for (i = 0; mem_handlers[i].name; i++) {
++ fprintf(stderr, " '%s'\n", mem_handlers[i].name);
++ }
++/* See http://support.microsoft.com/kb/190351 */
++#ifdef PHP_WIN32
++ fflush(stderr);
++#endif
++ exit(255);
++ }
++ }
++ handlers = &mem_handlers[i];
++
++ tmp = getenv("ZEND_MM_SEG_SIZE");
++ if (tmp) {
++ seg_size = zend_atoi(tmp, 0);
++ if (zend_mm_low_bit(seg_size) != zend_mm_high_bit(seg_size)) {
++ fprintf(stderr, "ZEND_MM_SEG_SIZE must be a power of two\n");
++/* See http://support.microsoft.com/kb/190351 */
++#ifdef PHP_WIN32
++ fflush(stderr);
++#endif
++ exit(255);
++ } else if (seg_size < ZEND_MM_ALIGNED_SEGMENT_SIZE + ZEND_MM_ALIGNED_HEADER_SIZE) {
++ fprintf(stderr, "ZEND_MM_SEG_SIZE is too small\n");
++/* See http://support.microsoft.com/kb/190351 */
++#ifdef PHP_WIN32
++ fflush(stderr);
++#endif
++ exit(255);
++ }
++ } else {
++ seg_size = ZEND_MM_SEG_SIZE;
++ }
++
++ heap = __zend_mm_startup_canary_ex(handlers, seg_size, ZEND_MM_RESERVE_SIZE, 0, NULL);
++ if (heap) {
++ tmp = getenv("ZEND_MM_COMPACT");
++ if (tmp) {
++ heap->compact_size = zend_atoi(tmp, 0);
++ } else {
++ heap->compact_size = 2 * 1024 * 1024;
++ }
++ }
++ return heap;
++}
++
++#if ZEND_DEBUG
++static long zend_mm_find_leaks(zend_mm_segment *segment, zend_mm_block_canary *b)
++{
++ long leaks = 0;
++ zend_mm_block_canary *p, *q;
++
++ p = ZEND_MM_NEXT_BLOCK(b);
++ while (1) {
++ if (ZEND_MM_IS_GUARD_BLOCK(p)) {
++ ZEND_MM_CHECK_MAGIC(p, MEM_BLOCK_GUARD);
++ segment = segment->next_segment;
++ if (!segment) {
++ break;
++ }
++ p = (zend_mm_block_canary *) ((char *) segment + ZEND_MM_ALIGNED_SEGMENT_SIZE);
++ continue;
++ }
++ q = ZEND_MM_NEXT_BLOCK(p);
++ if (q <= p ||
++ (char*)q > (char*)segment + segment->size ||
++ p->info._size != q->info._prev) {
++ zend_mm_panic("zend_mm_heap corrupted");
++ }
++ if (!ZEND_MM_IS_FREE_BLOCK(p)) {
++ if (p->magic == MEM_BLOCK_VALID) {
++ if (p->debug.filename==b->debug.filename && p->debug.lineno==b->debug.lineno) {
++ ZEND_MM_SET_MAGIC(p, MEM_BLOCK_LEAK);
++ leaks++;
++ }
++#if ZEND_MM_CACHE
++ } else if (p->magic == MEM_BLOCK_CACHED) {
++ /* skip it */
++#endif
++ } else if (p->magic != MEM_BLOCK_LEAK) {
++ zend_mm_panic("zend_mm_heap corrupted");
++ }
++ }
++ p = q;
++ }
++ return leaks;
++}
++
++static void zend_mm_check_leaks(zend_mm_heap_canary *heap TSRMLS_DC)
++{
++ zend_mm_segment *segment = heap->segments_list;
++ zend_mm_block_canary *p, *q;
++ zend_uint total = 0;
++
++ if (!segment) {
++ return;
++ }
++ p = (zend_mm_block_canary *) ((char *) segment + ZEND_MM_ALIGNED_SEGMENT_SIZE);
++ while (1) {
++ q = ZEND_MM_NEXT_BLOCK(p);
++ if (q <= p ||
++ (char*)q > (char*)segment + segment->size ||
++ p->info._size != q->info._prev) {
++ zend_mm_panic("zend_mm_heap corrupted");
++ }
++ if (!ZEND_MM_IS_FREE_BLOCK(p)) {
++ if (p->magic == MEM_BLOCK_VALID) {
++ long repeated;
++ zend_leak_info leak;
++
++ ZEND_MM_SET_MAGIC(p, MEM_BLOCK_LEAK);
++
++ leak.addr = ZEND_MM_DATA_OF(p);
++ leak.size = p->debug.size;
++ leak.filename = p->debug.filename;
++ leak.lineno = p->debug.lineno;
++ leak.orig_filename = p->debug.orig_filename;
++ leak.orig_lineno = p->debug.orig_lineno;
++
++ zend_message_dispatcher(ZMSG_LOG_SCRIPT_NAME, NULL TSRMLS_CC);
++ zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, &leak TSRMLS_CC);
++ repeated = zend_mm_find_leaks(segment, p);
++ total += 1 + repeated;
++ if (repeated) {
++ zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(zend_uintptr_t)repeated TSRMLS_CC);
++ }
++#if ZEND_MM_CACHE
++ } else if (p->magic == MEM_BLOCK_CACHED) {
++ /* skip it */
++#endif
++ } else if (p->magic != MEM_BLOCK_LEAK) {
++ zend_mm_panic("zend_mm_heap corrupted");
++ }
++ }
++ if (ZEND_MM_IS_GUARD_BLOCK(q)) {
++ segment = segment->next_segment;
++ if (!segment) {
++ break;
++ }
++ q = (zend_mm_block_canary *) ((char *) segment + ZEND_MM_ALIGNED_SEGMENT_SIZE);
++ }
++ p = q;
++ }
++ if (total) {
++ zend_message_dispatcher(ZMSG_MEMORY_LEAKS_GRAND_TOTAL, &total TSRMLS_CC);
++ }
++}
++
++static int zend_mm_check_ptr(zend_mm_heap_canary *heap, void *ptr, int silent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
++{
++ zend_mm_block_canary *p;
++ int no_cache_notice = 0;
++ int had_problems = 0;
++ int valid_beginning = 1;
++
++ if (silent==2) {
++ silent = 1;
++ no_cache_notice = 1;
++ } else if (silent==3) {
++ silent = 0;
++ no_cache_notice = 1;
++ }
++ if (!silent) {
++ TSRMLS_FETCH();
++
++ zend_message_dispatcher(ZMSG_LOG_SCRIPT_NAME, NULL TSRMLS_CC);
++ zend_debug_alloc_output("---------------------------------------\n");
++ zend_debug_alloc_output("%s(%d) : Block "PTR_FMT" status:\n" ZEND_FILE_LINE_RELAY_CC, ptr);
++ if (__zend_orig_filename) {
++ zend_debug_alloc_output("%s(%d) : Actual location (location was relayed)\n" ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ if (!ptr) {
++ zend_debug_alloc_output("NULL\n");
++ zend_debug_alloc_output("---------------------------------------\n");
++ return 0;
++ }
++ }
++
++ if (!ptr) {
++ if (silent) {
++ return zend_mm_check_ptr(heap, ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ }
++
++ p = ZEND_MM_HEADER_OF(ptr);
++
++#ifdef ZTS
++ if (ZEND_MM_BAD_THREAD_ID(p)) {
++ if (!silent) {
++ zend_debug_alloc_output("Invalid pointer: ((thread_id=0x%0.8X) != (expected=0x%0.8X))\n", (long)p->thread_id, (long)tsrm_thread_id());
++ had_problems = 1;
++ } else {
++ return zend_mm_check_ptr(heap, ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ }
++#endif
++
++ if (p->info._size != ZEND_MM_NEXT_BLOCK(p)->info._prev) {
++ if (!silent) {
++ zend_debug_alloc_output("Invalid pointer: ((size="PTR_FMT") != (next.prev="PTR_FMT"))\n", p->info._size, ZEND_MM_NEXT_BLOCK(p)->info._prev);
++ had_problems = 1;
++ } else {
++ return zend_mm_check_ptr(heap, ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ }
++ if (p->info._prev != ZEND_MM_GUARD_BLOCK &&
++ ZEND_MM_PREV_BLOCK(p)->info._size != p->info._prev) {
++ if (!silent) {
++ zend_debug_alloc_output("Invalid pointer: ((prev="PTR_FMT") != (prev.size="PTR_FMT"))\n", p->info._prev, ZEND_MM_PREV_BLOCK(p)->info._size);
++ had_problems = 1;
++ } else {
++ return zend_mm_check_ptr(heap, ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ }
++
++ if (had_problems) {
++ zend_debug_alloc_output("---------------------------------------\n");
++ return 0;
++ }
++
++ if (!silent) {
++ zend_debug_alloc_output("%10s\t","Beginning: ");
++ }
++
++ if (!ZEND_MM_IS_USED_BLOCK(p)) {
++ if (!silent) {
++ if (p->magic != MEM_BLOCK_FREED) {
++ zend_debug_alloc_output("Freed (magic=0x%0.8X, expected=0x%0.8X)\n", p->magic, MEM_BLOCK_FREED);
++ } else {
++ zend_debug_alloc_output("Freed\n");
++ }
++ had_problems = 1;
++ } else {
++ return zend_mm_check_ptr(heap, ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ } else if (ZEND_MM_IS_GUARD_BLOCK(p)) {
++ if (!silent) {
++ if (p->magic != MEM_BLOCK_FREED) {
++ zend_debug_alloc_output("Guard (magic=0x%0.8X, expected=0x%0.8X)\n", p->magic, MEM_BLOCK_FREED);
++ } else {
++ zend_debug_alloc_output("Guard\n");
++ }
++ had_problems = 1;
++ } else {
++ return zend_mm_check_ptr(heap, ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ } else {
++ switch (p->magic) {
++ case MEM_BLOCK_VALID:
++ case MEM_BLOCK_LEAK:
++ if (!silent) {
++ zend_debug_alloc_output("OK (allocated on %s:%d, %d bytes)\n", p->debug.filename, p->debug.lineno, (int)p->debug.size);
++ }
++ break; /* ok */
++ case MEM_BLOCK_CACHED:
++ if (!no_cache_notice) {
++ if (!silent) {
++ zend_debug_alloc_output("Cached\n");
++ had_problems = 1;
++ } else {
++ return zend_mm_check_ptr(heap, ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ }
++ case MEM_BLOCK_FREED:
++ if (!silent) {
++ zend_debug_alloc_output("Freed (invalid)\n");
++ had_problems = 1;
++ } else {
++ return zend_mm_check_ptr(heap, ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ break;
++ case MEM_BLOCK_GUARD:
++ if (!silent) {
++ zend_debug_alloc_output("Guard (invalid)\n");
++ had_problems = 1;
++ } else {
++ return zend_mm_check_ptr(heap, ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ break;
++ default:
++ if (!silent) {
++ zend_debug_alloc_output("Unknown (magic=0x%0.8X, expected=0x%0.8X)\n", p->magic, MEM_BLOCK_VALID);
++ had_problems = 1;
++ valid_beginning = 0;
++ } else {
++ return zend_mm_check_ptr(heap, ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ break;
++ }
++ }
++
++#if ZEND_MM_HEAP_PROTECTION
++ if (!valid_beginning) {
++ if (!silent) {
++ zend_debug_alloc_output("%10s\t", "Start:");
++ zend_debug_alloc_output("Unknown\n");
++ zend_debug_alloc_output("%10s\t", "End:");
++ zend_debug_alloc_output("Unknown\n");
++ }
++ } else {
++ char *end_magic = ZEND_MM_END_MAGIC_PTR(p);
++
++ if (p->debug.start_magic == _mem_block_start_magic) {
++ if (!silent) {
++ zend_debug_alloc_output("%10s\t", "Start:");
++ zend_debug_alloc_output("OK\n");
++ }
++ } else {
++ char *overflow_ptr, *magic_ptr=(char *) &_mem_block_start_magic;
++ int overflows=0;
++ int i;
++
++ if (silent) {
++ return _mem_block_check(ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ had_problems = 1;
++ overflow_ptr = (char *) &p->debug.start_magic;
++ i = END_MAGIC_SIZE;
++ while (--i >= 0) {
++ if (overflow_ptr[i]!=magic_ptr[i]) {
++ overflows++;
++ }
++ }
++ zend_debug_alloc_output("%10s\t", "Start:");
++ zend_debug_alloc_output("Overflown (magic=0x%0.8X instead of 0x%0.8X)\n", p->debug.start_magic, _mem_block_start_magic);
++ zend_debug_alloc_output("%10s\t","");
++ if (overflows >= END_MAGIC_SIZE) {
++ zend_debug_alloc_output("At least %d bytes overflown\n", END_MAGIC_SIZE);
++ } else {
++ zend_debug_alloc_output("%d byte(s) overflown\n", overflows);
++ }
++ }
++ if (memcmp(end_magic, &_mem_block_end_magic, END_MAGIC_SIZE)==0) {
++ if (!silent) {
++ zend_debug_alloc_output("%10s\t", "End:");
++ zend_debug_alloc_output("OK\n");
++ }
++ } else {
++ char *overflow_ptr, *magic_ptr=(char *) &_mem_block_end_magic;
++ int overflows=0;
++ int i;
++
++ if (silent) {
++ return _mem_block_check(ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ had_problems = 1;
++ overflow_ptr = (char *) end_magic;
++
++ for (i=0; i < END_MAGIC_SIZE; i++) {
++ if (overflow_ptr[i]!=magic_ptr[i]) {
++ overflows++;
++ }
++ }
++
++ zend_debug_alloc_output("%10s\t", "End:");
++ zend_debug_alloc_output("Overflown (magic=0x%0.8X instead of 0x%0.8X)\n", *end_magic, _mem_block_end_magic);
++ zend_debug_alloc_output("%10s\t","");
++ if (overflows >= END_MAGIC_SIZE) {
++ zend_debug_alloc_output("At least %d bytes overflown\n", END_MAGIC_SIZE);
++ } else {
++ zend_debug_alloc_output("%d byte(s) overflown\n", overflows);
++ }
++ }
++ }
++#endif
++
++ if (!silent) {
++ zend_debug_alloc_output("---------------------------------------\n");
++ }
++ return ((!had_problems) ? 1 : 0);
++}
++
++static int zend_mm_check_heap(zend_mm_heap_canary *heap, int silent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
++{
++ zend_mm_segment *segment = heap->segments_list;
++ zend_mm_block_canary *p, *q;
++ int errors = 0;
++
++ if (!segment) {
++ return 0;
++ }
++ p = (zend_mm_block_canary *) ((char *) segment + ZEND_MM_ALIGNED_SEGMENT_SIZE);
++ while (1) {
++ q = ZEND_MM_NEXT_BLOCK(p);
++ if (q <= p ||
++ (char*)q > (char*)segment + segment->size ||
++ p->info._size != q->info._prev) {
++ zend_mm_panic("zend_mm_heap corrupted");
++ }
++ if (!ZEND_MM_IS_FREE_BLOCK(p)) {
++ if (p->magic == MEM_BLOCK_VALID || p->magic == MEM_BLOCK_LEAK) {
++ if (!zend_mm_check_ptr(heap, ZEND_MM_DATA_OF(p), (silent?2:3) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC)) {
++ errors++;
++ }
++#if ZEND_MM_CACHE
++ } else if (p->magic == MEM_BLOCK_CACHED) {
++ /* skip it */
++#endif
++ } else if (p->magic != MEM_BLOCK_LEAK) {
++ zend_mm_panic("zend_mm_heap corrupted");
++ }
++ }
++ if (ZEND_MM_IS_GUARD_BLOCK(q)) {
++ segment = segment->next_segment;
++ if (!segment) {
++ return errors;
++ }
++ q = (zend_mm_block_canary *) ((char *) segment + ZEND_MM_ALIGNED_SEGMENT_SIZE);
++ }
++ p = q;
++ }
++}
++#endif
++
++void __zend_mm_shutdown_canary(zend_mm_heap_canary *heap, int full_shutdown, int silent TSRMLS_DC)
++{
++ zend_mm_storage *storage;
++ zend_mm_segment *segment;
++ zend_mm_segment *prev;
++ int internal;
++
++ if (heap->reserve) {
++#if ZEND_DEBUG
++ if (!silent) {
++ _zend_mm_free(heap, heap->reserve ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
++ }
++#endif
++ heap->reserve = NULL;
++ }
++
++#if ZEND_MM_CACHE_STAT
++ if (full_shutdown) {
++ FILE *f;
++
++ f = fopen("zend_mm.log", "w");
++ if (f) {
++ int i,j;
++ size_t size, true_size, min_size, max_size;
++ int hit = 0, miss = 0;
++
++ fprintf(f, "\nidx min_size max_size true_size max_len hits misses\n");
++ size = 0;
++ while (1) {
++ true_size = ZEND_MM_TRUE_SIZE(size);
++ if (ZEND_MM_SMALL_SIZE(true_size)) {
++ min_size = size;
++ i = ZEND_MM_BUCKET_INDEX(true_size);
++ size++;
++ while (1) {
++ true_size = ZEND_MM_TRUE_SIZE(size);
++ if (ZEND_MM_SMALL_SIZE(true_size)) {
++ j = ZEND_MM_BUCKET_INDEX(true_size);
++ if (j > i) {
++ max_size = size-1;
++ break;
++ }
++ } else {
++ max_size = size-1;
++ break;
++ }
++ size++;
++ }
++ hit += heap->cache_stat[i].hit;
++ miss += heap->cache_stat[i].miss;
++ fprintf(f, "%2d %8d %8d %9d %8d %8d %8d\n", i, (int)min_size, (int)max_size, ZEND_MM_TRUE_SIZE(max_size), heap->cache_stat[i].max_count, heap->cache_stat[i].hit, heap->cache_stat[i].miss);
++ } else {
++ break;
++ }
++ }
++ fprintf(f, " %8d %8d\n", hit, miss);
++ fprintf(f, " %8d %8d\n", heap->cache_stat[ZEND_MM_NUM_BUCKETS].hit, heap->cache_stat[ZEND_MM_NUM_BUCKETS].miss);
++ fclose(f);
++ }
++ }
++#endif
++
++#if ZEND_DEBUG
++ if (!silent) {
++ zend_mm_check_leaks(heap TSRMLS_CC);
++ }
++#endif
++
++ internal = heap->internal;
++ storage = heap->storage;
++ segment = heap->segments_list;
++ while (segment) {
++ prev = segment;
++ segment = segment->next_segment;
++ ZEND_MM_STORAGE_FREE(prev);
++ }
++ if (full_shutdown) {
++ storage->handlers->dtor(storage);
++ if (!internal) {
++ free(heap);
++ }
++ } else {
++ if (heap->compact_size &&
++ heap->real_peak > heap->compact_size) {
++ storage->handlers->compact(storage);
++ }
++ heap->segments_list = NULL;
++ zend_mm_init(heap);
++ heap->real_size = 0;
++ heap->real_peak = 0;
++ heap->size = 0;
++ heap->peak = 0;
++ if (heap->reserve_size) {
++ heap->reserve = _zend_mm_alloc((zend_mm_heap *)heap, heap->reserve_size ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
++ }
++ heap->overflow = 0;
++ }
++}
++
++static void zend_mm_safe_error(zend_mm_heap_canary *heap,
++ const char *format,
++ size_t limit,
++#if ZEND_DEBUG
++ const char *filename,
++ uint lineno,
++#endif
++ size_t size)
++{
++ if (heap->reserve) {
++ _zend_mm_free_canary_int(heap, heap->reserve ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
++ heap->reserve = NULL;
++ }
++ if (heap->overflow == 0) {
++ char *error_filename;
++ uint error_lineno;
++ TSRMLS_FETCH();
++ if (zend_is_compiling(TSRMLS_C)) {
++ error_filename = zend_get_compiled_filename(TSRMLS_C);
++ error_lineno = zend_get_compiled_lineno(TSRMLS_C);
++ } else if (EG(in_execution)) {
++ error_filename = EG(active_op_array)?EG(active_op_array)->filename:NULL;
++ error_lineno = EG(opline_ptr)?(*EG(opline_ptr))->lineno:0;
++ } else {
++ error_filename = NULL;
++ error_lineno = 0;
++ }
++ if (!error_filename) {
++ error_filename = "Unknown";
++ }
++ heap->overflow = 1;
++ zend_try {
++ zend_error_noreturn(E_ERROR,
++ format,
++ limit,
++#if ZEND_DEBUG
++ filename,
++ lineno,
++#endif
++ size);
++ } zend_catch {
++ if (heap->overflow == 2) {
++ fprintf(stderr, "\nFatal error: ");
++ fprintf(stderr,
++ format,
++ limit,
++#if ZEND_DEBUG
++ filename,
++ lineno,
++#endif
++ size);
++ fprintf(stderr, " in %s on line %d\n", error_filename, error_lineno);
++ }
++/* See http://support.microsoft.com/kb/190351 */
++#ifdef PHP_WIN32
++ fflush(stderr);
++#endif
++ } zend_end_try();
++ } else {
++ heap->overflow = 2;
++ }
++ zend_bailout();
++}
++
++static zend_mm_free_block_canary *zend_mm_search_large_block(zend_mm_heap_canary *heap, size_t true_size)
++{
++ zend_mm_free_block_canary *best_fit;
++ size_t index = ZEND_MM_LARGE_BUCKET_INDEX(true_size);
++ size_t bitmap = heap->large_free_bitmap >> index;
++ zend_mm_free_block_canary *p;
++
++ if (bitmap == 0) {
++ return NULL;
++ }
++
++ if (UNEXPECTED((bitmap & 1) != 0)) {
++ /* Search for best "large" free block */
++ zend_mm_free_block_canary *rst = NULL;
++ size_t m;
++ size_t best_size = -1;
++
++ best_fit = NULL;
++ p = heap->large_free_buckets[index];
++ for (m = true_size << (ZEND_MM_NUM_BUCKETS - index); ; m <<= 1) {
++ if (UNEXPECTED(ZEND_MM_FREE_BLOCK_SIZE(p) == true_size)) {
++ return SUHOSIN_MANGLE_PTR(p->next_free_block);
++ } else if (ZEND_MM_FREE_BLOCK_SIZE(p) >= true_size &&
++ ZEND_MM_FREE_BLOCK_SIZE(p) < best_size) {
++ best_size = ZEND_MM_FREE_BLOCK_SIZE(p);
++ best_fit = p;
++ }
++ if ((m & (ZEND_MM_LONG_CONST(1) << (ZEND_MM_NUM_BUCKETS-1))) == 0) {
++ if (p->child[1]) {
++ rst = p->child[1];
++ }
++ if (p->child[0]) {
++ p = p->child[0];
++ } else {
++ break;
++ }
++ } else if (p->child[1]) {
++ p = p->child[1];
++ } else {
++ break;
++ }
++ }
++
++ for (p = rst; p; p = p->child[p->child[0] != NULL]) {
++ if (UNEXPECTED(ZEND_MM_FREE_BLOCK_SIZE(p) == true_size)) {
++ return SUHOSIN_MANGLE_PTR(p->next_free_block);
++ } else if (ZEND_MM_FREE_BLOCK_SIZE(p) > true_size &&
++ ZEND_MM_FREE_BLOCK_SIZE(p) < best_size) {
++ best_size = ZEND_MM_FREE_BLOCK_SIZE(p);
++ best_fit = p;
++ }
++ }
++
++ if (best_fit) {
++ return SUHOSIN_MANGLE_PTR(best_fit->next_free_block);
++ }
++ bitmap = bitmap >> 1;
++ if (!bitmap) {
++ return NULL;
++ }
++ index++;
++ }
++
++ /* Search for smallest "large" free block */
++ best_fit = p = heap->large_free_buckets[index + zend_mm_low_bit(bitmap)];
++ while ((p = p->child[p->child[0] != NULL])) {
++ if (ZEND_MM_FREE_BLOCK_SIZE(p) < ZEND_MM_FREE_BLOCK_SIZE(best_fit)) {
++ best_fit = p;
++ }
++ }
++ return SUHOSIN_MANGLE_PTR(best_fit->next_free_block);
++}
++
++void *_zend_mm_alloc_canary_int(zend_mm_heap_canary *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
++{
++ zend_mm_free_block_canary *best_fit;
++ size_t true_size = ZEND_MM_TRUE_SIZE(size);
++ size_t block_size;
++ size_t remaining_size;
++ size_t segment_size;
++ zend_mm_segment *segment;
++ int keep_rest = 0;
++
++ if (EXPECTED(ZEND_MM_SMALL_SIZE(true_size))) {
++ size_t index = ZEND_MM_BUCKET_INDEX(true_size);
++ size_t bitmap;
++
++ if (UNEXPECTED(true_size < size)) {
++ goto out_of_memory;
++ }
++#if ZEND_MM_CACHE
++ if (EXPECTED(heap->cache[index] != NULL)) {
++ /* Get block from cache */
++#if ZEND_MM_CACHE_STAT
++ heap->cache_stat[index].count--;
++ heap->cache_stat[index].hit++;
++#endif
++ best_fit = SUHOSIN_MANGLE_PTR(heap->cache[index]);
++ heap->cache[index] = best_fit->prev_free_block;
++ heap->cached -= true_size;
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_SET_CANARIES(best_fit);
++ ((zend_mm_block_canary*)best_fit)->info.size = size;
++ SUHOSIN_MM_SET_END_CANARY(best_fit);
++#endif
++ ZEND_MM_CHECK_MAGIC(best_fit, MEM_BLOCK_CACHED);
++ ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 0);
++ return ZEND_MM_DATA_OF(best_fit);
++ }
++#if ZEND_MM_CACHE_STAT
++ heap->cache_stat[index].miss++;
++#endif
++#endif
++
++ bitmap = heap->free_bitmap >> index;
++ if (bitmap) {
++ /* Found some "small" free block that can be used */
++ index += zend_mm_low_bit(bitmap);
++ best_fit = SUHOSIN_MANGLE_PTR(heap->free_buckets[index*2]);
++#if ZEND_MM_CACHE_STAT
++ heap->cache_stat[ZEND_MM_NUM_BUCKETS].hit++;
++#endif
++ goto zend_mm_finished_searching_for_block;
++ }
++ }
++
++#if ZEND_MM_CACHE_STAT
++ heap->cache_stat[ZEND_MM_NUM_BUCKETS].miss++;
++#endif
++
++ best_fit = zend_mm_search_large_block(heap, true_size);
++
++ if (!best_fit && heap->real_size >= heap->limit - heap->block_size) {
++ zend_mm_free_block_canary *p = SUHOSIN_MANGLE_PTR(heap->rest_buckets[0]);
++ size_t best_size = -1;
++
++ while (p != ZEND_MM_REST_BUCKET(heap)) {
++ if (UNEXPECTED(ZEND_MM_FREE_BLOCK_SIZE(p) == true_size)) {
++ best_fit = p;
++ goto zend_mm_finished_searching_for_block;
++ } else if (ZEND_MM_FREE_BLOCK_SIZE(p) > true_size &&
++ ZEND_MM_FREE_BLOCK_SIZE(p) < best_size) {
++ best_size = ZEND_MM_FREE_BLOCK_SIZE(p);
++ best_fit = p;
++ }
++ p = SUHOSIN_MANGLE_PTR(p->prev_free_block);
++ }
++ }
++
++ if (!best_fit) {
++ if (true_size > heap->block_size - (ZEND_MM_ALIGNED_SEGMENT_SIZE + ZEND_MM_ALIGNED_HEADER_SIZE)) {
++ /* Make sure we add a memory block which is big enough,
++ segment must have header "size" and trailer "guard" block */
++ segment_size = true_size + ZEND_MM_ALIGNED_SEGMENT_SIZE + ZEND_MM_ALIGNED_HEADER_SIZE;
++ segment_size = (segment_size + (heap->block_size-1)) & ~(heap->block_size-1);
++ keep_rest = 1;
++ } else {
++ segment_size = heap->block_size;
++ }
++
++ HANDLE_BLOCK_INTERRUPTIONS();
++
++ if (segment_size < true_size ||
++ heap->real_size + segment_size > heap->limit) {
++ /* Memory limit overflow */
++#if ZEND_MM_CACHE
++ zend_mm_free_cache(heap);
++#endif
++ HANDLE_UNBLOCK_INTERRUPTIONS();
++#if ZEND_DEBUG
++ zend_mm_safe_error(heap, "Allowed memory size of %ld bytes exhausted at %s:%d (tried to allocate %lu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
++#else
++ zend_mm_safe_error(heap, "Allowed memory size of %ld bytes exhausted (tried to allocate %lu bytes)", heap->limit, size);
++#endif
++ }
++
++ segment = (zend_mm_segment *) ZEND_MM_STORAGE_ALLOC(segment_size);
++
++ if (!segment) {
++ /* Storage manager cannot allocate memory */
++#if ZEND_MM_CACHE
++ zend_mm_free_cache(heap);
++#endif
++ HANDLE_UNBLOCK_INTERRUPTIONS();
++out_of_memory:
++#if ZEND_DEBUG
++ zend_mm_safe_error(heap, "Out of memory (allocated %ld) at %s:%d (tried to allocate %lu bytes)", heap->real_size, __zend_filename, __zend_lineno, size);
++#else
++ zend_mm_safe_error(heap, "Out of memory (allocated %ld) (tried to allocate %lu bytes)", heap->real_size, size);
++#endif
++ return NULL;
++ }
++
++ heap->real_size += segment_size;
++ if (heap->real_size > heap->real_peak) {
++ heap->real_peak = heap->real_size;
++ }
++
++ segment->size = segment_size;
++ segment->next_segment = heap->segments_list;
++ heap->segments_list = segment;
++
++ best_fit = (zend_mm_free_block_canary *) ((char *) segment + ZEND_MM_ALIGNED_SEGMENT_SIZE);
++ ZEND_MM_MARK_FIRST_BLOCK(best_fit);
++
++ block_size = segment_size - ZEND_MM_ALIGNED_SEGMENT_SIZE - ZEND_MM_ALIGNED_HEADER_SIZE;
++
++ ZEND_MM_LAST_BLOCK(ZEND_MM_BLOCK_AT(best_fit, block_size));
++
++ } else {
++zend_mm_finished_searching_for_block:
++ /* remove from free list */
++ HANDLE_BLOCK_INTERRUPTIONS();
++ ZEND_MM_CHECK_MAGIC(best_fit, MEM_BLOCK_FREED);
++ ZEND_MM_CHECK_COOKIE(best_fit);
++ ZEND_MM_CHECK_BLOCK_LINKAGE(best_fit);
++ zend_mm_remove_from_free_list(heap, best_fit);
++
++ block_size = ZEND_MM_FREE_BLOCK_SIZE(best_fit);
++ }
++
++ remaining_size = block_size - true_size;
++
++ if (remaining_size < ZEND_MM_ALIGNED_MIN_HEADER_SIZE) {
++ true_size = block_size;
++ ZEND_MM_BLOCK(best_fit, ZEND_MM_USED_BLOCK, true_size);
++ } else {
++ zend_mm_free_block_canary *new_free_block;
++
++ /* prepare new free block */
++ ZEND_MM_BLOCK(best_fit, ZEND_MM_USED_BLOCK, true_size);
++ new_free_block = (zend_mm_free_block_canary *) ZEND_MM_BLOCK_AT(best_fit, true_size);
++ ZEND_MM_BLOCK(new_free_block, ZEND_MM_FREE_BLOCK, remaining_size);
++
++ /* add the new free block to the free list */
++ if (EXPECTED(!keep_rest)) {
++ zend_mm_add_to_free_list(heap, new_free_block);
++ } else {
++ zend_mm_add_to_rest_list(heap, new_free_block);
++ }
++ }
++
++ ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 1);
++
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_SET_CANARIES(best_fit);
++ ((zend_mm_block_canary*)best_fit)->info.size = size;
++ SUHOSIN_MM_SET_END_CANARY(best_fit);
++#endif
++
++ heap->size += true_size;
++ if (heap->peak < heap->size) {
++ heap->peak = heap->size;
++ }
++
++ HANDLE_UNBLOCK_INTERRUPTIONS();
++ return ZEND_MM_DATA_OF(best_fit);
++}
++
++
++void _zend_mm_free_canary_int(zend_mm_heap_canary *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
++{
++ zend_mm_block_canary *mm_block;
++ zend_mm_block_canary *next_block;
++ size_t size;
++
++ if (!ZEND_MM_VALID_PTR(p)) {
++ return;
++ }
++
++ mm_block = ZEND_MM_HEADER_OF(p);
++ size = ZEND_MM_BLOCK_SIZE(mm_block);
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_CHECK_CANARIES(mm_block, "efree()");
++#endif
++ ZEND_MM_CHECK_PROTECTION(mm_block);
++
++#if ZEND_DEBUG || ZEND_MM_HEAP_PROTECTION
++ memset(ZEND_MM_DATA_OF(mm_block), 0x5a, mm_block->debug.size);
++#endif
++#if SUHOSIN_PATCH
++ if (UNEXPECTED(SUHOSIN_CONFIG(SUHOSIN_MM_DESTROY_FREE_MEMORY))) {
++ memset(ZEND_MM_DATA_OF(mm_block), 0x5a, mm_block->info.size);
++ }
++#endif
++#if ZEND_MM_CACHE
++ if (EXPECTED(ZEND_MM_SMALL_SIZE(size)) && EXPECTED(heap->cached < ZEND_MM_CACHE_SIZE)) {
++ size_t index = ZEND_MM_BUCKET_INDEX(size);
++ zend_mm_free_block_canary **cache = &heap->cache[index];
++
++ ((zend_mm_free_block_canary*)mm_block)->prev_free_block = *cache;
++ *cache = (zend_mm_free_block_canary*)SUHOSIN_MANGLE_PTR(mm_block);
++ heap->cached += size;
++ ZEND_MM_SET_MAGIC(mm_block, MEM_BLOCK_CACHED);
++#if ZEND_MM_CACHE_STAT
++ if (++heap->cache_stat[index].count > heap->cache_stat[index].max_count) {
++ heap->cache_stat[index].max_count = heap->cache_stat[index].count;
++ }
++#endif
++ return;
++ }
++#endif
++
++ HANDLE_BLOCK_INTERRUPTIONS();
++
++ heap->size -= size;
++
++ next_block = ZEND_MM_BLOCK_AT(mm_block, size);
++ if (ZEND_MM_IS_FREE_BLOCK(next_block)) {
++ zend_mm_remove_from_free_list(heap, (zend_mm_free_block_canary *) next_block);
++ size += ZEND_MM_FREE_BLOCK_SIZE(next_block);
++ }
++ if (ZEND_MM_PREV_BLOCK_IS_FREE(mm_block)) {
++ mm_block = ZEND_MM_PREV_BLOCK(mm_block);
++ zend_mm_remove_from_free_list(heap, (zend_mm_free_block_canary *) mm_block);
++ size += ZEND_MM_FREE_BLOCK_SIZE(mm_block);
++ }
++ if (ZEND_MM_IS_FIRST_BLOCK(mm_block) &&
++ ZEND_MM_IS_GUARD_BLOCK(ZEND_MM_BLOCK_AT(mm_block, size))) {
++ zend_mm_del_segment(heap, (zend_mm_segment *) ((char *)mm_block - ZEND_MM_ALIGNED_SEGMENT_SIZE));
++ } else {
++ ZEND_MM_BLOCK(mm_block, ZEND_MM_FREE_BLOCK, size);
++ zend_mm_add_to_free_list(heap, (zend_mm_free_block_canary *) mm_block);
++ }
++ HANDLE_UNBLOCK_INTERRUPTIONS();
++}
++
++void *_zend_mm_realloc_canary_int(zend_mm_heap_canary *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
++{
++ zend_mm_block_canary *mm_block = ZEND_MM_HEADER_OF(p);
++ zend_mm_block_canary *next_block;
++ size_t true_size;
++ size_t orig_size;
++ void *ptr;
++
++ if (UNEXPECTED(!p) || !ZEND_MM_VALID_PTR(p)) {
++ return _zend_mm_alloc_canary_int(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ }
++ mm_block = ZEND_MM_HEADER_OF(p);
++ true_size = ZEND_MM_TRUE_SIZE(size);
++ orig_size = ZEND_MM_BLOCK_SIZE(mm_block);
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_CHECK_CANARIES(mm_block, "erealloc()");
++#endif
++ ZEND_MM_CHECK_PROTECTION(mm_block);
++
++ if (UNEXPECTED(true_size < size)) {
++ goto out_of_memory;
++ }
++
++ if (true_size <= orig_size) {
++ size_t remaining_size = orig_size - true_size;
++
++ if (remaining_size >= ZEND_MM_ALIGNED_MIN_HEADER_SIZE) {
++ zend_mm_free_block_canary *new_free_block;
++
++ HANDLE_BLOCK_INTERRUPTIONS();
++ next_block = ZEND_MM_BLOCK_AT(mm_block, orig_size);
++ if (ZEND_MM_IS_FREE_BLOCK(next_block)) {
++ remaining_size += ZEND_MM_FREE_BLOCK_SIZE(next_block);
++ zend_mm_remove_from_free_list(heap, (zend_mm_free_block_canary *) next_block);
++ }
++
++ /* prepare new free block */
++ ZEND_MM_BLOCK(mm_block, ZEND_MM_USED_BLOCK, true_size);
++ new_free_block = (zend_mm_free_block_canary *) ZEND_MM_BLOCK_AT(mm_block, true_size);
++
++ ZEND_MM_BLOCK(new_free_block, ZEND_MM_FREE_BLOCK, remaining_size);
++
++ /* add the new free block to the free list */
++ zend_mm_add_to_free_list(heap, new_free_block);
++ heap->size += (true_size - orig_size);
++ HANDLE_UNBLOCK_INTERRUPTIONS();
++ }
++ ZEND_MM_SET_DEBUG_INFO(mm_block, size, 0, 0);
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_SET_CANARIES(mm_block);
++ ((zend_mm_block_canary*)mm_block)->info.size = size;
++ SUHOSIN_MM_SET_END_CANARY(mm_block);
++#endif
++ return p;
++ }
++
++#if ZEND_MM_CACHE
++ if (ZEND_MM_SMALL_SIZE(true_size)) {
++ size_t index = ZEND_MM_BUCKET_INDEX(true_size);
++
++ if (heap->cache[index] != NULL) {
++ zend_mm_free_block_canary *best_fit;
++ zend_mm_free_block_canary **cache;
++
++#if ZEND_MM_CACHE_STAT
++ heap->cache_stat[index].count--;
++ heap->cache_stat[index].hit++;
++#endif
++ best_fit = SUHOSIN_MANGLE_PTR(heap->cache[index]);
++ heap->cache[index] = best_fit->prev_free_block;
++ ZEND_MM_CHECK_MAGIC(best_fit, MEM_BLOCK_CACHED);
++ ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 0);
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_SET_CANARIES(best_fit);
++ ((zend_mm_block_canary*)best_fit)->info.size = size;
++ SUHOSIN_MM_SET_END_CANARY(best_fit);
++#endif
++
++ ptr = ZEND_MM_DATA_OF(best_fit);
++
++#if ZEND_DEBUG || ZEND_MM_HEAP_PROTECTION
++ memcpy(ptr, p, mm_block->debug.size);
++#else
++ memcpy(ptr, p, orig_size - ZEND_MM_ALIGNED_HEADER_SIZE - CANARY_SIZE);
++#endif
++
++ heap->cached -= true_size - orig_size;
++
++ index = ZEND_MM_BUCKET_INDEX(orig_size);
++ cache = &heap->cache[index];
++
++ ((zend_mm_free_block_canary*)mm_block)->prev_free_block = *cache;
++ *cache = (zend_mm_free_block_canary*)SUHOSIN_MANGLE_PTR(mm_block);
++ ZEND_MM_SET_MAGIC(mm_block, MEM_BLOCK_CACHED);
++#if ZEND_MM_CACHE_STAT
++ if (++heap->cache_stat[index].count > heap->cache_stat[index].max_count) {
++ heap->cache_stat[index].max_count = heap->cache_stat[index].count;
++ }
++#endif
++ return ptr;
++ }
++ }
++#endif
++
++ next_block = ZEND_MM_BLOCK_AT(mm_block, orig_size);
++
++ if (ZEND_MM_IS_FREE_BLOCK(next_block)) {
++ ZEND_MM_CHECK_COOKIE(next_block);
++ ZEND_MM_CHECK_BLOCK_LINKAGE(next_block);
++ if (orig_size + ZEND_MM_FREE_BLOCK_SIZE(next_block) >= true_size) {
++ size_t block_size = orig_size + ZEND_MM_FREE_BLOCK_SIZE(next_block);
++ size_t remaining_size = block_size - true_size;
++
++ HANDLE_BLOCK_INTERRUPTIONS();
++ zend_mm_remove_from_free_list(heap, (zend_mm_free_block_canary *) next_block);
++
++ if (remaining_size < ZEND_MM_ALIGNED_MIN_HEADER_SIZE) {
++ true_size = block_size;
++ ZEND_MM_BLOCK(mm_block, ZEND_MM_USED_BLOCK, true_size);
++ } else {
++ zend_mm_free_block_canary *new_free_block;
++
++ /* prepare new free block */
++ ZEND_MM_BLOCK(mm_block, ZEND_MM_USED_BLOCK, true_size);
++ new_free_block = (zend_mm_free_block_canary *) ZEND_MM_BLOCK_AT(mm_block, true_size);
++ ZEND_MM_BLOCK(new_free_block, ZEND_MM_FREE_BLOCK, remaining_size);
++
++ /* add the new free block to the free list */
++ if (ZEND_MM_IS_FIRST_BLOCK(mm_block) &&
++ ZEND_MM_IS_GUARD_BLOCK(ZEND_MM_BLOCK_AT(new_free_block, remaining_size))) {
++ zend_mm_add_to_rest_list(heap, new_free_block);
++ } else {
++ zend_mm_add_to_free_list(heap, new_free_block);
++ }
++ }
++ ZEND_MM_SET_DEBUG_INFO(mm_block, size, 0, 0);
++ heap->size = heap->size + true_size - orig_size;
++ if (heap->peak < heap->size) {
++ heap->peak = heap->size;
++ }
++ HANDLE_UNBLOCK_INTERRUPTIONS();
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_SET_CANARIES(mm_block);
++ ((zend_mm_block_canary*)mm_block)->info.size = size;
++ SUHOSIN_MM_SET_END_CANARY(mm_block);
++#endif
++ return p;
++ } else if (ZEND_MM_IS_FIRST_BLOCK(mm_block) &&
++ ZEND_MM_IS_GUARD_BLOCK(ZEND_MM_BLOCK_AT(next_block, ZEND_MM_FREE_BLOCK_SIZE(next_block)))) {
++ HANDLE_BLOCK_INTERRUPTIONS();
++ zend_mm_remove_from_free_list(heap, (zend_mm_free_block_canary *) next_block);
++ goto realloc_segment;
++ }
++ } else if (ZEND_MM_IS_FIRST_BLOCK(mm_block) && ZEND_MM_IS_GUARD_BLOCK(next_block)) {
++ zend_mm_segment *segment;
++ zend_mm_segment *segment_copy;
++ size_t segment_size;
++ size_t block_size;
++ size_t remaining_size;
++
++ HANDLE_BLOCK_INTERRUPTIONS();
++realloc_segment:
++ /* segment size, size of block and size of guard block */
++ if (true_size > heap->block_size - (ZEND_MM_ALIGNED_SEGMENT_SIZE + ZEND_MM_ALIGNED_HEADER_SIZE)) {
++ segment_size = true_size+ZEND_MM_ALIGNED_SEGMENT_SIZE+ZEND_MM_ALIGNED_HEADER_SIZE;
++ segment_size = (segment_size + (heap->block_size-1)) & ~(heap->block_size-1);
++ } else {
++ segment_size = heap->block_size;
++ }
++
++ segment_copy = (zend_mm_segment *) ((char *)mm_block - ZEND_MM_ALIGNED_SEGMENT_SIZE);
++ if (segment_size < true_size ||
++ heap->real_size + segment_size - segment_copy->size > heap->limit) {
++ if (ZEND_MM_IS_FREE_BLOCK(next_block)) {
++ zend_mm_add_to_free_list(heap, (zend_mm_free_block_canary *) next_block);
++ }
++#if ZEND_MM_CACHE
++ zend_mm_free_cache(heap);
++#endif
++ HANDLE_UNBLOCK_INTERRUPTIONS();
++#if ZEND_DEBUG
++ zend_mm_safe_error(heap, "Allowed memory size of %ld bytes exhausted at %s:%d (tried to allocate %ld bytes)", heap->limit, __zend_filename, __zend_lineno, size);
++#else
++ zend_mm_safe_error(heap, "Allowed memory size of %ld bytes exhausted (tried to allocate %ld bytes)", heap->limit, size);
++#endif
++ return NULL;
++ }
++
++ segment = ZEND_MM_STORAGE_REALLOC(segment_copy, segment_size);
++ if (!segment) {
++#if ZEND_MM_CACHE
++ zend_mm_free_cache(heap);
++#endif
++ HANDLE_UNBLOCK_INTERRUPTIONS();
++out_of_memory:
++#if ZEND_DEBUG
++ zend_mm_safe_error(heap, "Out of memory (allocated %ld) at %s:%d (tried to allocate %ld bytes)", heap->real_size, __zend_filename, __zend_lineno, size);
++#else
++ zend_mm_safe_error(heap, "Out of memory (allocated %ld) (tried to allocate %ld bytes)", heap->real_size, size);
++#endif
++ return NULL;
++ }
++ heap->real_size += segment_size - segment->size;
++ if (heap->real_size > heap->real_peak) {
++ heap->real_peak = heap->real_size;
++ }
++
++ segment->size = segment_size;
++
++ if (segment != segment_copy) {
++ zend_mm_segment **seg = &heap->segments_list;
++ while (*seg != segment_copy) {
++ seg = &(*seg)->next_segment;
++ }
++ *seg = segment;
++ mm_block = (zend_mm_block_canary *) ((char *) segment + ZEND_MM_ALIGNED_SEGMENT_SIZE);
++ ZEND_MM_MARK_FIRST_BLOCK(mm_block);
++ }
++
++ block_size = segment_size - ZEND_MM_ALIGNED_SEGMENT_SIZE - ZEND_MM_ALIGNED_HEADER_SIZE;
++ remaining_size = block_size - true_size;
++
++ /* setup guard block */
++ ZEND_MM_LAST_BLOCK(ZEND_MM_BLOCK_AT(mm_block, block_size));
++
++ if (remaining_size < ZEND_MM_ALIGNED_MIN_HEADER_SIZE) {
++ true_size = block_size;
++ ZEND_MM_BLOCK(mm_block, ZEND_MM_USED_BLOCK, true_size);
++ } else {
++ zend_mm_free_block_canary *new_free_block;
++
++ /* prepare new free block */
++ ZEND_MM_BLOCK(mm_block, ZEND_MM_USED_BLOCK, true_size);
++ new_free_block = (zend_mm_free_block_canary *) ZEND_MM_BLOCK_AT(mm_block, true_size);
++ ZEND_MM_BLOCK(new_free_block, ZEND_MM_FREE_BLOCK, remaining_size);
++
++ /* add the new free block to the free list */
++ zend_mm_add_to_rest_list(heap, new_free_block);
++ }
++
++ ZEND_MM_SET_DEBUG_INFO(mm_block, size, 1, 1);
++
++ heap->size = heap->size + true_size - orig_size;
++ if (heap->peak < heap->size) {
++ heap->peak = heap->size;
++ }
++
++ HANDLE_UNBLOCK_INTERRUPTIONS();
++#if SUHOSIN_PATCH
++ SUHOSIN_MM_SET_CANARIES(mm_block);
++ ((zend_mm_block_canary*)mm_block)->info.size = size;
++ SUHOSIN_MM_SET_END_CANARY(mm_block);
++#endif
++ return ZEND_MM_DATA_OF(mm_block);
++ }
++
++ ptr = _zend_mm_alloc_canary_int(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++#if ZEND_DEBUG || ZEND_MM_HEAP_PROTECTION
++ memcpy(ptr, p, mm_block->debug.size);
++#else
++ memcpy(ptr, p, orig_size - ZEND_MM_ALIGNED_HEADER_SIZE - CANARY_SIZE);
++#endif
++ _zend_mm_free_canary_int(heap, p ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
++ return ptr;
++}
++
++ZEND_API size_t _zend_mm_block_size_canary(zend_mm_heap_canary *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
++{
++ zend_mm_block_canary *mm_block;
++
++ if (!ZEND_MM_VALID_PTR(p)) {
++ return 0;
++ }
++ mm_block = ZEND_MM_HEADER_OF(p);
++ ZEND_MM_CHECK_PROTECTION(mm_block);
++#if ZEND_DEBUG || ZEND_MM_HEAP_PROTECTION
++ return mm_block->debug.size;
++#else
++ return ZEND_MM_BLOCK_SIZE(mm_block);
++#endif
++}
++
++#if defined(__GNUC__) && defined(i386)
++
++static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
++{
++ size_t res = nmemb;
++ unsigned long overflow = 0;
++
++ __asm__ ("mull %3\n\taddl %4,%0\n\tadcl %1,%1"
++ : "=&a"(res), "=&d" (overflow)
++ : "%0"(res),
++ "rm"(size),
++ "rm"(offset));
++
++ if (UNEXPECTED(overflow)) {
++ zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
++ return 0;
++ }
++ return res;
++}
++
++#elif defined(__GNUC__) && defined(__x86_64__)
++
++static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
++{
++ size_t res = nmemb;
++ unsigned long overflow = 0;
++
++ __asm__ ("mulq %3\n\taddq %4,%0\n\tadcq %1,%1"
++ : "=&a"(res), "=&d" (overflow)
++ : "%0"(res),
++ "rm"(size),
++ "rm"(offset));
++
++ if (UNEXPECTED(overflow)) {
++ zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
++ return 0;
++ }
++ return res;
++}
++
++#elif SIZEOF_SIZE_T == 4 && defined(HAVE_ZEND_LONG64)
++
++static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
++{
++ zend_ulong64 res = (zend_ulong64)nmemb * (zend_ulong64)size + (zend_ulong64)offset;
++
++ if (UNEXPECTED(res > (zend_ulong64)0xFFFFFFFFL)) {
++ zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
++ return 0;
++ }
++ return (size_t) res;
++}
++
++#else
++
++static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
++{
++ size_t res = nmemb * size + offset;
++ double _d = (double)nmemb * (double)size + (double)offset;
++ double _delta = (double)res - _d;
++
++ if (UNEXPECTED((_d + _delta ) != _d)) {
++ zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
++ return 0;
++ }
++ return res;
++}
++#endif
++
++/*
++ * Local variables:
++ * tab-width: 4
++ * c-basic-offset: 4
++ * indent-tabs-mode: t
++ * End:
++ */
++
+diff -Naurp php-5.3.6RC1/Zend/zend_alloc.h php-5.3.6RC1.oden/Zend/zend_alloc.h
+--- php-5.3.6RC1/Zend/zend_alloc.h 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/zend_alloc.h 2011-02-20 11:50:19.320838976 +0100
+@@ -203,6 +203,8 @@ END_EXTERN_C()
+
+ /* Heap functions */
+ typedef struct _zend_mm_heap zend_mm_heap;
++typedef struct _zend_mm_heap_canary zend_mm_heap_canary;
++
+
+ ZEND_API zend_mm_heap *zend_mm_startup(void);
+ ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, int full_shutdown, int silent TSRMLS_DC);
+diff -Naurp php-5.3.6RC1/Zend/zend.c php-5.3.6RC1.oden/Zend/zend.c
+--- php-5.3.6RC1/Zend/zend.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/zend.c 2011-02-20 11:50:19.321839116 +0100
+@@ -60,6 +60,10 @@ int (*zend_vspprintf)(char **pbuf, size_
+ ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
+ ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
+
++#if SUHOSIN_PATCH
++ZEND_API void (*zend_suhosin_log)(int loglevel, char *fmt, ...);
++#endif
++
+ void (*zend_on_timeout)(int seconds TSRMLS_DC);
+
+ static void (*zend_message_dispatcher_p)(long message, void *data TSRMLS_DC);
+@@ -88,6 +92,74 @@ static ZEND_INI_MH(OnUpdateGCEnabled) /*
+ }
+ /* }}} */
+
++#if SUHOSIN_PATCH
++static ZEND_INI_MH(OnUpdateSuhosin_log_syslog)
++{
++ if (!new_value) {
++ SPG(log_syslog) = S_ALL & ~S_SQL | S_MEMORY;
++ } else {
++ SPG(log_syslog) = atoi(new_value) | S_MEMORY;
++ }
++ return SUCCESS;
++}
++static ZEND_INI_MH(OnUpdateSuhosin_log_syslog_facility)
++{
++ if (!new_value) {
++ SPG(log_syslog_facility) = LOG_USER;
++ } else {
++ SPG(log_syslog_facility) = atoi(new_value);
++ }
++ return SUCCESS;
++}
++static ZEND_INI_MH(OnUpdateSuhosin_log_syslog_priority)
++{
++ if (!new_value) {
++ SPG(log_syslog_priority) = LOG_ALERT;
++ } else {
++ SPG(log_syslog_priority) = atoi(new_value);
++ }
++ return SUCCESS;
++}
++static ZEND_INI_MH(OnUpdateSuhosin_log_sapi)
++{
++ if (!new_value) {
++ SPG(log_sapi) = S_ALL & ~S_SQL;
++ } else {
++ SPG(log_sapi) = atoi(new_value);
++ }
++ return SUCCESS;
++}
++static ZEND_INI_MH(OnUpdateSuhosin_log_script)
++{
++ if (!new_value) {
++ SPG(log_script) = S_ALL & ~S_MEMORY;
++ } else {
++ SPG(log_script) = atoi(new_value) & (~S_MEMORY) & (~S_INTERNAL);
++ }
++ return SUCCESS;
++}
++static ZEND_INI_MH(OnUpdateSuhosin_log_scriptname)
++{
++ if (SPG(log_scriptname)) {
++ pefree(SPG(log_scriptname),1);
++ }
++ SPG(log_scriptname) = NULL;
++ if (new_value) {
++ SPG(log_scriptname) = pestrdup(new_value,1);
++ }
++ return SUCCESS;
++}
++static ZEND_INI_MH(OnUpdateSuhosin_log_phpscript)
++{
++ if (!new_value) {
++ SPG(log_phpscript) = S_ALL & ~S_MEMORY;
++ } else {
++ SPG(log_phpscript) = atoi(new_value) & (~S_MEMORY) & (~S_INTERNAL);
++ }
++ return SUCCESS;
++}
++#endif
++
+ ZEND_INI_BEGIN()
+ ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting)
+ STD_ZEND_INI_BOOLEAN("zend.enable_gc", "1", ZEND_INI_ALL, OnUpdateGCEnabled, gc_enabled, zend_gc_globals, gc_globals)
+diff -Naurp php-5.3.6RC1/Zend/zend_canary.c php-5.3.6RC1.oden/Zend/zend_canary.c
+--- php-5.3.6RC1/Zend/zend_canary.c 1970-01-01 01:00:00.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/zend_canary.c 2011-02-20 11:50:19.322839257 +0100
+@@ -0,0 +1,66 @@
++/*
++ +----------------------------------------------------------------------+
++ | Suhosin-Patch for PHP |
++ +----------------------------------------------------------------------+
++ | Copyright (c) 2004-2009 Stefan Esser |
++ +----------------------------------------------------------------------+
++ | This source file is subject to version 2.02 of the PHP license, |
++ | that is bundled with this package in the file LICENSE, and is |
++ | available at through the world-wide-web at |
++ | http://www.php.net/license/2_02.txt. |
++ | If you did not receive a copy of the PHP license and are unable to |
++ | obtain it through the world-wide-web, please send a note to |
++ | license@php.net so we can mail you a copy immediately. |
++ +----------------------------------------------------------------------+
++ | Author: Stefan Esser <stefan.esser@sektioneins.de> |
++ +----------------------------------------------------------------------+
++ */
++/* $Id$ */
++
++#include "zend.h"
++
++#include <stdio.h>
++#include <stdlib.h>
++
++
++#if SUHOSIN_PATCH
++
++static size_t last_canary = 0x73625123;
++
++/* will be replaced later with more compatible method */
++ZEND_API void zend_canary(void *buf, int len)
++{
++ time_t t;
++ size_t canary;
++ int fd;
++
++#ifndef PHP_WIN32
++ fd = open("/dev/urandom", 0);
++ if (fd != -1) {
++ int r = read(fd, buf, len);
++ close(fd);
++ if (r == len) {
++ return;
++ }
++ }
++#endif
++ /* not good but we never want to do this */
++ time(&t);
++ canary = *(unsigned int *)&t + getpid() << 16 + last_canary;
++ last_canary ^= (canary << 5) | (canary >> (32-5));
++ /* When we ensure full win32 compatibility in next version
++ we will replace this with the random number code from zend_alloc.c */
++ memcpy(buf, &canary, len);
++}
++
++#endif
++
++
++/*
++ * Local variables:
++ * tab-width: 4
++ * c-basic-offset: 4
++ * End:
++ * vim600: sw=4 ts=4 fdm=marker
++ * vim<600: sw=4 ts=4
++ */
+diff -Naurp php-5.3.6RC1/Zend/zend_compile.c php-5.3.6RC1.oden/Zend/zend_compile.c
+--- php-5.3.6RC1/Zend/zend_compile.c 2011-01-19 18:17:52.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/zend_compile.c 2011-02-20 11:50:19.323839398 +0100
+@@ -73,6 +73,11 @@ static void zend_destroy_property_info_i
+ }
+ /* }}} */
+
++#if SUHOSIN_PATCH
++void *suhosin_zend_destroy_property_info_internal = zend_destroy_property_info_internal;
++void *suhosin_zend_destroy_property_info = zend_destroy_property_info;
++#endif
++
+ static void build_runtime_defined_function_key(zval *result, const char *name, int name_length TSRMLS_DC) /* {{{ */
+ {
+ char char_pos_buf[32];
+diff -Naurp php-5.3.6RC1/Zend/zend_compile.h php-5.3.6RC1.oden/Zend/zend_compile.h
+--- php-5.3.6RC1/Zend/zend_compile.h 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/zend_compile.h 2011-02-20 11:50:19.324839539 +0100
+@@ -606,6 +606,11 @@ ZEND_API zend_bool zend_is_auto_global(c
+ ZEND_API int zend_auto_global_disable_jit(const char *varname, zend_uint varname_length TSRMLS_DC);
+ ZEND_API size_t zend_dirname(char *path, size_t len);
+
++#if SUHOSIN_PATCH
++extern void *suhosin_zend_destroy_property_info_internal;
++extern void *suhosin_zend_destroy_property_info;
++#endif
++
+ int zendlex(znode *zendlval TSRMLS_DC);
+
+ /* BEGIN: OPCODES */
+diff -Naurp php-5.3.6RC1/Zend/zend_constants.c php-5.3.6RC1.oden/Zend/zend_constants.c
+--- php-5.3.6RC1/Zend/zend_constants.c 2011-01-16 21:39:22.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/zend_constants.c 2011-02-20 11:52:28.887065479 +0100
+@@ -115,6 +115,77 @@ void zend_register_standard_constants(TS
+
+ REGISTER_MAIN_LONG_CONSTANT("DEBUG_BACKTRACE_PROVIDE_OBJECT", DEBUG_BACKTRACE_PROVIDE_OBJECT, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("DEBUG_BACKTRACE_IGNORE_ARGS", DEBUG_BACKTRACE_IGNORE_ARGS, CONST_PERSISTENT | CONST_CS);
++
++#if SUHOSIN_PATCH
++ REGISTER_MAIN_LONG_CONSTANT("S_MEMORY", S_MEMORY, CONST_PERSISTENT | CONST_CS);
++ REGISTER_MAIN_LONG_CONSTANT("S_VARS", S_VARS, CONST_PERSISTENT | CONST_CS);
++ REGISTER_MAIN_LONG_CONSTANT("S_FILES", S_FILES, CONST_PERSISTENT | CONST_CS);
++ REGISTER_MAIN_LONG_CONSTANT("S_INCLUDE", S_INCLUDE, CONST_PERSISTENT | CONST_CS);
++ REGISTER_MAIN_LONG_CONSTANT("S_SQL", S_SQL, CONST_PERSISTENT | CONST_CS);
++ REGISTER_MAIN_LONG_CONSTANT("S_EXECUTOR", S_EXECUTOR, CONST_PERSISTENT | CONST_CS);
++ REGISTER_MAIN_LONG_CONSTANT("S_MAIL", S_MAIL, CONST_PERSISTENT | CONST_CS);
++ REGISTER_MAIN_LONG_CONSTANT("S_SESSION", S_SESSION, CONST_PERSISTENT | CONST_CS);
++ REGISTER_MAIN_LONG_CONSTANT("S_MISC", S_MISC, CONST_PERSISTENT | CONST_CS);
++ REGISTER_MAIN_LONG_CONSTANT("S_INTERNAL", S_INTERNAL, CONST_PERSISTENT | CONST_CS);
++ REGISTER_MAIN_LONG_CONSTANT("S_ALL", S_ALL, CONST_PERSISTENT | CONST_CS);
++
++ /* error levels */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_EMERG", LOG_EMERG, CONST_CS | CONST_PERSISTENT); /* system unusable */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_ALERT", LOG_ALERT, CONST_CS | CONST_PERSISTENT); /* immediate action required */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_CRIT", LOG_CRIT, CONST_CS | CONST_PERSISTENT); /* critical conditions */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_ERR", LOG_ERR, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_WARNING", LOG_WARNING, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_NOTICE", LOG_NOTICE, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_INFO", LOG_INFO, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_DEBUG", LOG_DEBUG, CONST_CS | CONST_PERSISTENT);
++ /* facility: type of program logging the message */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_KERN", LOG_KERN, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_USER", LOG_USER, CONST_CS | CONST_PERSISTENT); /* generic user level */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_MAIL", LOG_MAIL, CONST_CS | CONST_PERSISTENT); /* log to email */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_DAEMON", LOG_DAEMON, CONST_CS | CONST_PERSISTENT); /* other system daemons */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_AUTH", LOG_AUTH, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_SYSLOG", LOG_SYSLOG, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_LPR", LOG_LPR, CONST_CS | CONST_PERSISTENT);
++#ifdef LOG_NEWS
++ /* No LOG_NEWS on HP-UX */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_NEWS", LOG_NEWS, CONST_CS | CONST_PERSISTENT); /* usenet new */
++#endif
++#ifdef LOG_UUCP
++ /* No LOG_UUCP on HP-UX */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_UUCP", LOG_UUCP, CONST_CS | CONST_PERSISTENT);
++#endif
++#ifdef LOG_CRON
++ /* apparently some systems don't have this one */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_CRON", LOG_CRON, CONST_CS | CONST_PERSISTENT);
++#endif
++#ifdef LOG_AUTHPRIV
++ /* AIX doesn't have LOG_AUTHPRIV */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_AUTHPRIV", LOG_AUTHPRIV, CONST_CS | CONST_PERSISTENT);
++#endif
++#ifndef PHP_WIN32
++ REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL0", LOG_LOCAL0, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL1", LOG_LOCAL1, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL2", LOG_LOCAL2, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL3", LOG_LOCAL3, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL4", LOG_LOCAL4, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL5", LOG_LOCAL5, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL6", LOG_LOCAL6, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_LOCAL7", LOG_LOCAL7, CONST_CS | CONST_PERSISTENT);
++#endif
++ /* options */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_PID", LOG_PID, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_CONS", LOG_CONS, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_ODELAY", LOG_ODELAY, CONST_CS | CONST_PERSISTENT);
++ REGISTER_MAIN_LONG_CONSTANT("LOG_NDELAY", LOG_NDELAY, CONST_CS | CONST_PERSISTENT);
++#ifdef LOG_NOWAIT
++ REGISTER_MAIN_LONG_CONSTANT("LOG_NOWAIT", LOG_NOWAIT, CONST_CS | CONST_PERSISTENT);
++#endif
++#ifdef LOG_PERROR
++ /* AIX doesn't have LOG_PERROR */
++ REGISTER_MAIN_LONG_CONSTANT("LOG_PERROR", LOG_PERROR, CONST_CS | CONST_PERSISTENT); /*log to stderr*/
++#endif
++#endif
++
+ /* true/false constants */
+ {
+ zend_constant c;
+diff -Naurp php-5.3.6RC1/Zend/zend_errors.h php-5.3.6RC1.oden/Zend/zend_errors.h
+--- php-5.3.6RC1/Zend/zend_errors.h 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/zend_errors.h 2011-02-20 11:50:19.326839821 +0100
+@@ -41,6 +41,20 @@
+ #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 | E_DEPRECATED | E_USER_DEPRECATED)
+ #define E_CORE (E_CORE_ERROR | E_CORE_WARNING)
+
++#if SUHOSIN_PATCH
++#define S_MEMORY (1<<0L)
++#define S_MISC (1<<1L)
++#define S_VARS (1<<2L)
++#define S_FILES (1<<3L)
++#define S_INCLUDE (1<<4L)
++#define S_SQL (1<<5L)
++#define S_EXECUTOR (1<<6L)
++#define S_MAIL (1<<7L)
++#define S_SESSION (1<<8L)
++#define S_INTERNAL (1<<29L)
++#define S_ALL (S_MEMORY | S_VARS | S_INCLUDE | S_FILES | S_MAIL | S_SESSION | S_MISC | S_SQL | S_EXECUTOR)
++#endif
++
+ #endif /* ZEND_ERRORS_H */
+
+ /*
+diff -Naurp php-5.3.6RC1/Zend/zend.h php-5.3.6RC1.oden/Zend/zend.h
+--- php-5.3.6RC1/Zend/zend.h 2011-02-20 11:45:04.146488357 +0100
++++ php-5.3.6RC1.oden/Zend/zend.h 2011-02-20 11:50:19.327839962 +0100
+@@ -627,6 +627,9 @@ extern ZEND_API int (*zend_stream_open_f
+ extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
+ extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
+ extern ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
++#if SUHOSIN_PATCH
++extern ZEND_API void (*zend_suhosin_log)(int loglevel, char *fmt, ...);
++#endif
+
+ ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
+
+@@ -774,6 +777,16 @@ ZEND_API void zend_restore_error_handlin
+ #define DEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0)
+ #define DEBUG_BACKTRACE_IGNORE_ARGS (1<<1)
+
++#if SUHOSIN_PATCH
++#include "suhosin_globals.h"
++#include "suhosin_patch.h"
++#include "php_syslog.h"
++
++ZEND_API void zend_canary(void *buf, int len);
++ZEND_API char suhosin_get_config(int element);
++
++#endif
++
+ #endif /* ZEND_H */
+
+ /*
+diff -Naurp php-5.3.6RC1/Zend/zend_hash.c php-5.3.6RC1.oden/Zend/zend_hash.c
+--- php-5.3.6RC1/Zend/zend_hash.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/zend_hash.c 2011-02-20 11:50:19.328840102 +0100
+@@ -20,6 +20,7 @@
+ /* $Id$ */
+
+ #include "zend.h"
++#include "zend_compile.h"
+
+ #define CONNECT_TO_BUCKET_DLLIST(element, list_head) \
+ (element)->pNext = (list_head); \
+@@ -136,6 +137,199 @@ ZEND_API ulong zend_hash_func(const char
+ }
+
+
++#if SUHOSIN_PATCH
++#ifdef ZTS
++static MUTEX_T zend_hash_dprot_mx_reader;
++static MUTEX_T zend_hash_dprot_mx_writer;
++static unsigned int zend_hash_dprot_reader;
++#endif
++static unsigned int zend_hash_dprot_counter;
++static unsigned int zend_hash_dprot_curmax;
++static dtor_func_t *zend_hash_dprot_table = NULL;
++
++static void zend_hash_dprot_begin_read()
++{
++#ifdef ZTS
++ tsrm_mutex_lock(zend_hash_dprot_mx_reader);
++ if ((++(zend_hash_dprot_reader)) == 1) {
++ tsrm_mutex_lock(zend_hash_dprot_mx_writer);
++ }
++ tsrm_mutex_unlock(zend_hash_dprot_mx_reader);
++#endif
++}
++
++static void zend_hash_dprot_end_read()
++{
++#ifdef ZTS
++ tsrm_mutex_lock(zend_hash_dprot_mx_reader);
++ if ((--(zend_hash_dprot_reader)) == 0) {
++ tsrm_mutex_unlock(zend_hash_dprot_mx_writer);
++ }
++ tsrm_mutex_unlock(zend_hash_dprot_mx_reader);
++#endif
++}
++
++static void zend_hash_dprot_begin_write()
++{
++#ifdef ZTS
++ tsrm_mutex_lock(zend_hash_dprot_mx_writer);
++#endif
++}
++
++static void zend_hash_dprot_end_write()
++{
++#ifdef ZTS
++ tsrm_mutex_unlock(zend_hash_dprot_mx_writer);
++#endif
++}
++
++/*ZEND_API void zend_hash_dprot_dtor()
++{
++#ifdef ZTS
++ tsrm_mutex_free(zend_hash_dprot_mx_reader);
++ tsrm_mutex_free(zend_hash_dprot_mx_writer);
++#endif
++ free(zend_hash_dprot_table);
++}*/
++
++static void zend_hash_add_destructor(dtor_func_t pDestructor)
++{
++ int left, right, mid;
++ zend_bool found = 0;
++ unsigned long value;
++
++ if (pDestructor == NULL || pDestructor == ZVAL_PTR_DTOR || pDestructor == ZVAL_INTERNAL_PTR_DTOR
++ || pDestructor == ZEND_FUNCTION_DTOR || pDestructor == ZEND_CLASS_DTOR) {
++ return;
++ }
++
++ if (zend_hash_dprot_table == NULL) {
++#ifdef ZTS
++ zend_hash_dprot_mx_reader = tsrm_mutex_alloc();
++ zend_hash_dprot_mx_writer = tsrm_mutex_alloc();
++ zend_hash_dprot_reader = 0;
++#endif
++ zend_hash_dprot_counter = 0;
++ zend_hash_dprot_curmax = 256;
++ zend_hash_dprot_table = (dtor_func_t *) malloc(256 * sizeof(dtor_func_t));
++ }
++
++ zend_hash_dprot_begin_write();
++
++ if (zend_hash_dprot_counter == 0) {
++ zend_hash_dprot_counter++;
++ zend_hash_dprot_table[0] = pDestructor;
++ } else {
++ value = (unsigned long) pDestructor;
++ left = 0;
++ right = zend_hash_dprot_counter-1;
++ mid = 0;
++
++ while (left < right) {
++ mid = (right - left) >> 1;
++ mid += left;
++ if ((unsigned long)zend_hash_dprot_table[mid] == value) {
++ found = 1;
++ break;
++ }
++ if (value < (unsigned long)zend_hash_dprot_table[mid]) {
++ right = mid-1;
++ } else {
++ left = mid+1;
++ }
++ }
++ if ((unsigned long)zend_hash_dprot_table[left] == value) {
++ found = 1;
++ }
++
++ if (!found) {
++
++ if (zend_hash_dprot_counter >= zend_hash_dprot_curmax) {
++ zend_hash_dprot_curmax += 256;
++ zend_hash_dprot_table = (dtor_func_t *) realloc(zend_hash_dprot_table, zend_hash_dprot_curmax * sizeof(dtor_func_t));
++ }
++
++ if ((unsigned long)zend_hash_dprot_table[left] < value) {
++ memmove(zend_hash_dprot_table+left+2, zend_hash_dprot_table+left+1, (zend_hash_dprot_counter-left-1)*sizeof(dtor_func_t));
++ zend_hash_dprot_table[left+1] = pDestructor;
++ } else {
++ memmove(zend_hash_dprot_table+left+1, zend_hash_dprot_table+left, (zend_hash_dprot_counter-left)*sizeof(dtor_func_t));
++ zend_hash_dprot_table[left] = pDestructor;
++ }
++
++ zend_hash_dprot_counter++;
++ }
++ }
++
++ zend_hash_dprot_end_write();
++}
++
++static void zend_hash_check_destructor(dtor_func_t pDestructor)
++{
++ unsigned long value;
++
++ if (pDestructor == NULL || pDestructor == ZVAL_PTR_DTOR || pDestructor == ZVAL_INTERNAL_PTR_DTOR
++#ifdef ZEND_ENGINE_2
++ || pDestructor == suhosin_zend_destroy_property_info_internal || pDestructor == suhosin_zend_destroy_property_info
++#endif
++ || pDestructor == ZEND_FUNCTION_DTOR || pDestructor == ZEND_CLASS_DTOR) {
++ return;
++ }
++
++ zend_hash_dprot_begin_read();
++
++ if (zend_hash_dprot_counter > 0) {
++ int left, right, mid;
++ zend_bool found = 0;
++
++ value = (unsigned long) pDestructor;
++ left = 0;
++ right = zend_hash_dprot_counter-1;
++
++ while (left < right) {
++ mid = (right - left) >> 1;
++ mid += left;
++ if ((unsigned long)zend_hash_dprot_table[mid] == value) {
++ found = 1;
++ break;
++ }
++ if (value < (unsigned long)zend_hash_dprot_table[mid]) {
++ right = mid-1;
++ } else {
++ left = mid+1;
++ }
++ }
++ if ((unsigned long)zend_hash_dprot_table[left] == value) {
++ found = 1;
++ }
++
++ if (!found) {
++ zend_hash_dprot_end_read();
++
++ zend_suhosin_log(S_MEMORY, "possible memory corruption detected - unknown Hashtable destructor");
++ if (SUHOSIN_CONFIG(SUHOSIN_HT_IGNORE_INVALID_DESTRUCTOR) == 0) {
++ _exit(1);
++ }
++ return;
++ }
++
++ } else {
++ zend_hash_dprot_end_read();
++
++ zend_suhosin_log(S_MEMORY, "possible memory corruption detected - unknown Hashtable destructor");
++ if (SUHOSIN_CONFIG(SUHOSIN_HT_IGNORE_INVALID_DESTRUCTOR) == 0) {
++ _exit(1);
++ }
++ return;
++ }
++
++ zend_hash_dprot_end_read();
++}
++
++#else
++#define zend_hash_add_destructor(pDestructor) do {} while(0)
++#define zend_hash_check_destructor(pDestructor) do {} while(0)
++#endif
+
+ 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)
+ {
+@@ -156,6 +350,7 @@ ZEND_API int _zend_hash_init(HashTable *
+
+ ht->nTableMask = ht->nTableSize - 1;
+ ht->pDestructor = pDestructor;
++ zend_hash_add_destructor(pDestructor);
+ ht->arBuckets = NULL;
+ ht->pListHead = NULL;
+ ht->pListTail = NULL;
+@@ -233,6 +428,7 @@ ZEND_API int _zend_hash_add_or_update(Ha
+ return FAILURE;
+ }
+ #endif
++ zend_hash_check_destructor(ht->pDestructor);
+ if (ht->pDestructor) {
+ ht->pDestructor(p->pData);
+ }
+@@ -298,6 +494,7 @@ ZEND_API int _zend_hash_quick_add_or_upd
+ return FAILURE;
+ }
+ #endif
++ zend_hash_check_destructor(ht->pDestructor);
+ if (ht->pDestructor) {
+ ht->pDestructor(p->pData);
+ }
+@@ -373,6 +570,7 @@ ZEND_API int _zend_hash_index_update_or_
+ return FAILURE;
+ }
+ #endif
++ zend_hash_check_destructor(ht->pDestructor);
+ if (ht->pDestructor) {
+ ht->pDestructor(p->pData);
+ }
+@@ -496,6 +694,7 @@ ZEND_API int zend_hash_del_key_or_index(
+ if (ht->pInternalPointer == p) {
+ ht->pInternalPointer = p->pListNext;
+ }
++ zend_hash_check_destructor(ht->pDestructor);
+ if (ht->pDestructor) {
+ ht->pDestructor(p->pData);
+ }
+@@ -522,6 +721,7 @@ ZEND_API void zend_hash_destroy(HashTabl
+ SET_INCONSISTENT(HT_IS_DESTROYING);
+
+ p = ht->pListHead;
++ zend_hash_check_destructor(ht->pDestructor);
+ while (p != NULL) {
+ q = p;
+ p = p->pListNext;
+@@ -548,6 +748,7 @@ ZEND_API void zend_hash_clean(HashTable
+ SET_INCONSISTENT(HT_CLEANING);
+
+ p = ht->pListHead;
++ zend_hash_check_destructor(ht->pDestructor);
+ while (p != NULL) {
+ q = p;
+ p = p->pListNext;
+@@ -610,6 +811,7 @@ static Bucket *zend_hash_apply_deleter(H
+ ht->nNumOfElements--;
+ HANDLE_UNBLOCK_INTERRUPTIONS();
+
++ zend_hash_check_destructor(ht->pDestructor);
+ if (ht->pDestructor) {
+ ht->pDestructor(p->pData);
+ }
+diff -Naurp php-5.3.6RC1/Zend/zend_llist.c php-5.3.6RC1.oden/Zend/zend_llist.c
+--- php-5.3.6RC1/Zend/zend_llist.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/zend_llist.c 2011-02-20 11:50:19.329840242 +0100
+@@ -23,6 +23,194 @@
+ #include "zend_llist.h"
+ #include "zend_qsort.h"
+
++#if SUHOSIN_PATCH
++#ifdef ZTS
++static MUTEX_T zend_llist_dprot_mx_reader;
++static MUTEX_T zend_llist_dprot_mx_writer;
++static unsigned int zend_llist_dprot_reader;
++#endif
++static unsigned int zend_llist_dprot_counter;
++static unsigned int zend_llist_dprot_curmax;
++static llist_dtor_func_t *zend_llist_dprot_table = NULL;
++
++static void zend_llist_dprot_begin_read()
++{
++#ifdef ZTS
++ tsrm_mutex_lock(zend_llist_dprot_mx_reader);
++ if ((++(zend_llist_dprot_reader)) == 1) {
++ tsrm_mutex_lock(zend_llist_dprot_mx_writer);
++ }
++ tsrm_mutex_unlock(zend_llist_dprot_mx_reader);
++#endif
++}
++
++static void zend_llist_dprot_end_read()
++{
++#ifdef ZTS
++ tsrm_mutex_lock(zend_llist_dprot_mx_reader);
++ if ((--(zend_llist_dprot_reader)) == 0) {
++ tsrm_mutex_unlock(zend_llist_dprot_mx_writer);
++ }
++ tsrm_mutex_unlock(zend_llist_dprot_mx_reader);
++#endif
++}
++
++static void zend_llist_dprot_begin_write()
++{
++#ifdef ZTS
++ tsrm_mutex_lock(zend_llist_dprot_mx_writer);
++#endif
++}
++
++static void zend_llist_dprot_end_write()
++{
++#ifdef ZTS
++ tsrm_mutex_unlock(zend_llist_dprot_mx_writer);
++#endif
++}
++
++/*ZEND_API void zend_llist_dprot_dtor()
++{
++#ifdef ZTS
++ tsrm_mutex_free(zend_llist_dprot_mx_reader);
++ tsrm_mutex_free(zend_llist_dprot_mx_writer);
++#endif
++ free(zend_llist_dprot_table);
++}*/
++
++static void zend_llist_add_destructor(llist_dtor_func_t pDestructor)
++{
++ int left, right, mid;
++ zend_bool found = 0;
++ unsigned long value;
++
++ if (pDestructor == NULL || pDestructor == ZVAL_PTR_DTOR) {
++ return;
++ }
++
++ if (zend_llist_dprot_table == NULL) {
++#ifdef ZTS
++ zend_llist_dprot_mx_reader = tsrm_mutex_alloc();
++ zend_llist_dprot_mx_writer = tsrm_mutex_alloc();
++ zend_llist_dprot_reader = 0;
++#endif
++ zend_llist_dprot_counter = 0;
++ zend_llist_dprot_curmax = 256;
++ zend_llist_dprot_table = (llist_dtor_func_t *) malloc(256 * sizeof(llist_dtor_func_t));
++ }
++
++ zend_llist_dprot_begin_write();
++
++ if (zend_llist_dprot_counter == 0) {
++ zend_llist_dprot_counter++;
++ zend_llist_dprot_table[0] = pDestructor;
++ } else {
++ value = (unsigned long) pDestructor;
++ left = 0;
++ right = zend_llist_dprot_counter-1;
++ mid = 0;
++
++ while (left < right) {
++ mid = (right - left) >> 1;
++ mid += left;
++ if ((unsigned long)zend_llist_dprot_table[mid] == value) {
++ found = 1;
++ break;
++ }
++ if (value < (unsigned long)zend_llist_dprot_table[mid]) {
++ right = mid-1;
++ } else {
++ left = mid+1;
++ }
++ }
++ if ((unsigned long)zend_llist_dprot_table[left] == value) {
++ found = 1;
++ }
++
++ if (!found) {
++
++ if (zend_llist_dprot_counter >= zend_llist_dprot_curmax) {
++ zend_llist_dprot_curmax += 256;
++ zend_llist_dprot_table = (llist_dtor_func_t *) realloc(zend_llist_dprot_table, zend_llist_dprot_curmax * sizeof(llist_dtor_func_t));
++ }
++
++ if ((unsigned long)zend_llist_dprot_table[left] < value) {
++ memmove(zend_llist_dprot_table+left+2, zend_llist_dprot_table+left+1, (zend_llist_dprot_counter-left-1)*sizeof(llist_dtor_func_t));
++ zend_llist_dprot_table[left+1] = pDestructor;
++ } else {
++ memmove(zend_llist_dprot_table+left+1, zend_llist_dprot_table+left, (zend_llist_dprot_counter-left)*sizeof(llist_dtor_func_t));
++ zend_llist_dprot_table[left] = pDestructor;
++ }
++
++ zend_llist_dprot_counter++;
++ }
++ }
++
++ zend_llist_dprot_end_write();
++}
++
++static void zend_llist_check_destructor(llist_dtor_func_t pDestructor)
++{
++ unsigned long value;
++
++ if (pDestructor == NULL || pDestructor == ZVAL_PTR_DTOR) {
++ return;
++ }
++
++ zend_llist_dprot_begin_read();
++
++ if (zend_llist_dprot_counter > 0) {
++ int left, right, mid;
++ zend_bool found = 0;
++
++ value = (unsigned long) pDestructor;
++ left = 0;
++ right = zend_llist_dprot_counter-1;
++
++ while (left < right) {
++ mid = (right - left) >> 1;
++ mid += left;
++ if ((unsigned long)zend_llist_dprot_table[mid] == value) {
++ found = 1;
++ break;
++ }
++ if (value < (unsigned long)zend_llist_dprot_table[mid]) {
++ right = mid-1;
++ } else {
++ left = mid+1;
++ }
++ }
++ if ((unsigned long)zend_llist_dprot_table[left] == value) {
++ found = 1;
++ }
++
++ if (!found) {
++ zend_llist_dprot_end_read();
++
++ zend_suhosin_log(S_MEMORY, "possible memory corruption detected - unknown llist destructor");
++ if (SUHOSIN_CONFIG(SUHOSIN_LL_IGNORE_INVALID_DESTRUCTOR) == 0) {
++ _exit(1);
++ }
++ return;
++ }
++
++ } else {
++ zend_llist_dprot_end_read();
++
++ zend_suhosin_log(S_MEMORY, "possible memory corruption detected - unknown llist destructor");
++ if (SUHOSIN_CONFIG(SUHOSIN_LL_IGNORE_INVALID_DESTRUCTOR) == 0) {
++ _exit(1);
++ }
++ return;
++ }
++
++ zend_llist_dprot_end_read();
++}
++#else
++#define zend_llist_add_destructor(pDestructor) do {} while(0)
++#define zend_llist_check_destructor(pDestructor) do {} while(0)
++#endif
++
+ ZEND_API void zend_llist_init(zend_llist *l, size_t size, llist_dtor_func_t dtor, unsigned char persistent)
+ {
+ l->head = NULL;
+@@ -30,6 +218,7 @@ ZEND_API void zend_llist_init(zend_llist
+ l->count = 0;
+ l->size = size;
+ l->dtor = dtor;
++ zend_llist_add_destructor(dtor);
+ l->persistent = persistent;
+ }
+
+@@ -81,6 +270,7 @@ ZEND_API void zend_llist_prepend_element
+ } else {\
+ (l)->tail = (current)->prev;\
+ }\
++ zend_llist_check_destructor((l)->dtor); \
+ if ((l)->dtor) {\
+ (l)->dtor((current)->data);\
+ }\
+@@ -108,6 +298,7 @@ ZEND_API void zend_llist_destroy(zend_ll
+ {
+ zend_llist_element *current=l->head, *next;
+
++ zend_llist_check_destructor(l->dtor);
+ while (current) {
+ next = current->next;
+ if (l->dtor) {
+@@ -133,6 +324,7 @@ ZEND_API void *zend_llist_remove_tail(ze
+ zend_llist_element *old_tail;
+ void *data;
+
++ zend_llist_check_destructor((l)->dtor);
+ if ((old_tail = l->tail)) {
+ if (old_tail->prev) {
+ old_tail->prev->next = NULL;
+diff -Naurp php-5.3.6RC1/Zend/zend_operators.c php-5.3.6RC1.oden/Zend/zend_operators.c
+--- php-5.3.6RC1/Zend/zend_operators.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/zend_operators.c 2011-02-20 11:50:19.330840383 +0100
+@@ -153,9 +153,14 @@ ZEND_API void convert_scalar_to_number(z
+ case IS_STRING:
+ {
+ char *strval;
++ int strl;
+
+ strval = Z_STRVAL_P(op);
+- if ((Z_TYPE_P(op)=is_numeric_string(strval, Z_STRLEN_P(op), &Z_LVAL_P(op), &Z_DVAL_P(op), 1)) == 0) {
++ strl = Z_STRLEN_P(op);
++#if SUHOSIN_PATCH
++ Z_STRLEN_P(op) = 0;
++#endif
++ if ((Z_TYPE_P(op)=is_numeric_string(strval, strl, &Z_LVAL_P(op), &Z_DVAL_P(op), 1)) == 0) {
+ ZVAL_LONG(op, 0);
+ }
+ STR_FREE(strval);
+@@ -187,7 +192,8 @@ ZEND_API void convert_scalar_to_number(z
+ } else { \
+ switch (Z_TYPE_P(op)) { \
+ case IS_STRING: \
+- { \
++ { \
++ Z_STRLEN(holder) = 0; \
+ if ((Z_TYPE(holder)=is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &Z_LVAL(holder), &Z_DVAL(holder), 1)) == 0) { \
+ ZVAL_LONG(&(holder), 0); \
+ } \
+@@ -229,6 +235,7 @@ ZEND_API void convert_scalar_to_number(z
+ Z_LVAL(holder) = zend_dval_to_lval(Z_DVAL_P(op)); \
+ break; \
+ case IS_STRING: \
++ Z_STRLEN(holder) = 0; \
+ Z_LVAL(holder) = strtol(Z_STRVAL_P(op), NULL, 10); \
+ break; \
+ case IS_ARRAY: \
+@@ -271,6 +278,7 @@ ZEND_API void convert_scalar_to_number(z
+ Z_LVAL(holder) = (Z_DVAL_P(op) ? 1 : 0); \
+ break; \
+ case IS_STRING: \
++ Z_STRLEN(holder) = 0; \
+ if (Z_STRLEN_P(op) == 0 \
+ || (Z_STRLEN_P(op)==1 && Z_STRVAL_P(op)[0]=='0')) { \
+ Z_LVAL(holder) = 0; \
+@@ -356,6 +364,9 @@ ZEND_API void convert_to_long_base(zval
+ {
+ char *strval = Z_STRVAL_P(op);
+
++#if SUHOSIN_PATCH
++ Z_STRLEN_P(op) = 0;
++#endif
+ Z_LVAL_P(op) = strtol(strval, NULL, base);
+ STR_FREE(strval);
+ }
+@@ -416,6 +427,9 @@ ZEND_API void convert_to_double(zval *op
+ {
+ char *strval = Z_STRVAL_P(op);
+
++#if SUHOSIN_PATCH
++ Z_STRLEN_P(op) = 0;
++#endif
+ Z_DVAL_P(op) = zend_strtod(strval, NULL);
+ STR_FREE(strval);
+ }
+@@ -502,8 +516,14 @@ ZEND_API void convert_to_boolean(zval *o
+
+ if (Z_STRLEN_P(op) == 0
+ || (Z_STRLEN_P(op)==1 && Z_STRVAL_P(op)[0]=='0')) {
++#if SUHOSIN_PATCH
++ Z_STRLEN_P(op) = 0;
++#endif
+ Z_LVAL_P(op) = 0;
+ } else {
++#if SUHOSIN_PATCH
++ Z_STRLEN_P(op) = 0;
++#endif
+ Z_LVAL_P(op) = 1;
+ }
+ STR_FREE(strval);
+@@ -617,6 +637,9 @@ static void convert_scalar_to_array(zval
+ *entry = *op;
+ INIT_PZVAL(entry);
+
++#if SUHOSIN_PATCH
++ Z_STRLEN_P(op) = 0;
++#endif
+ switch (type) {
+ case IS_ARRAY:
+ ALLOC_HASHTABLE(Z_ARRVAL_P(op));
+diff -Naurp php-5.3.6RC1/Zend/zend_variables.c php-5.3.6RC1.oden/Zend/zend_variables.c
+--- php-5.3.6RC1/Zend/zend_variables.c 2011-01-01 03:19:59.000000000 +0100
++++ php-5.3.6RC1.oden/Zend/zend_variables.c 2011-02-20 11:50:19.331840524 +0100
+@@ -34,6 +34,9 @@ ZEND_API void _zval_dtor_func(zval *zval
+ case IS_CONSTANT:
+ CHECK_ZVAL_STRING_REL(zvalue);
+ STR_FREE_REL(zvalue->value.str.val);
++#if SUHOSIN_PATCH
++ zvalue->value.str.len = 0;
++#endif
+ break;
+ case IS_ARRAY:
+ case IS_CONSTANT_ARRAY: {
+@@ -78,6 +81,9 @@ ZEND_API void _zval_internal_dtor(zval *
+ case IS_CONSTANT:
+ CHECK_ZVAL_STRING_REL(zvalue);
+ free(zvalue->value.str.val);
++#if SUHOSIN_PATCH
++ zvalue->value.str.len = 0;
++#endif
+ break;
+ case IS_ARRAY:
+ case IS_CONSTANT_ARRAY: