From e6f83ff85ff9f0aee5fb84a941ec5978c62af03c Mon Sep 17 00:00:00 2001 From: Marcin Krol Date: Fri, 13 Dec 2019 18:18:08 +0100 Subject: [PATCH] - updated to 7.4.0, partial PLD merge, release 0.1 (not tested yet) --- dep-tests.sh | 136 +- extension-shared-optional-dep.patch | 4 +- fix-test-run.patch | 13 +- intl-stdc++.patch | 4 +- mcrypt-libs.patch | 19 - milter.patch | 28 - mysqlnd-ssl.patch | 24 - opcache.ini | 37 +- pcre-shared.patch | 180 - phar-hash-shared.patch | 33 - php-both-apxs.patch | 4 +- php-build_modules.patch | 9 - php-cgi-fcgi.ini | 46 +- php-filter-shared.patch | 14 - php-fpm-config.patch | 4 +- php-fpm-shared.patch | 21 - php-ini.patch | 36 +- php-libtool.patch | 31 - php-link-libs.patch | 16 +- php-nohttpd.patch | 15 +- php-pear.patch | 45 - php-sapi-ini-file.patch | 122 +- php-shared.patch | 73 +- php-stupidapache_version.patch | 4 +- php-use-prog_sendmail.patch | 4 +- php.spec | 673 ++-- skip-tests.sh | 4 - spl-shared.patch | 33 - suhosin.patch | 5685 --------------------------- 29 files changed, 512 insertions(+), 6805 deletions(-) delete mode 100644 mcrypt-libs.patch delete mode 100644 milter.patch delete mode 100644 mysqlnd-ssl.patch delete mode 100644 pcre-shared.patch delete mode 100644 phar-hash-shared.patch delete mode 100644 php-build_modules.patch delete mode 100644 php-filter-shared.patch delete mode 100644 php-fpm-shared.patch delete mode 100644 php-libtool.patch delete mode 100644 php-pear.patch delete mode 100644 spl-shared.patch delete mode 100644 suhosin.patch diff --git a/dep-tests.sh b/dep-tests.sh index 18ea66c..062c2f8 100755 --- a/dep-tests.sh +++ b/dep-tests.sh @@ -3,60 +3,114 @@ with_mysqlnd=mysqlnd -dep_spl="pcre simplexml" -dep_session="spl $dep_spl" -dep_filter='pcre' +dep_session="" +dep_filter='' dep_eaccelerator='session' -dep_mysql="$with_mysqlnd" -dep_mysqli="$dep_spl spl $with_mysqlnd" -dep_pdo="$dep_spl spl" +dep_mysqlnd='' +dep_mysql="$dep_mysqlnd $with_mysqlnd" +dep_mysqli="$dep_mysqlnd $with_mysqlnd" +dep_pdo="" dep_pdo_sqlite="$dep_pdo pdo" dep_pdo_pgsql="$dep_pdo pdo" dep_pdo_oci="$dep_pdo pdo" dep_pdo_odbc="$dep_pdo pdo" dep_pdo_firebird="$dep_pdo pdo" dep_pdo_dblib="$dep_pdo pdo" -dep_pdo_mysql="$dep_pdo pdo $with_mysqlnd" -dep_simplexml="$dep_spl spl" -dep_imap="pcre" -dep_phar="$dep_spl spl hash" +dep_pdo_mysql="$dep_pdo pdo $dep_mysqlnd $with_mysqlnd" +dep_simplexml="" +dep_imap="" +dep_phar="" dep_sqlite="$dep_pdo pdo" -dep_fileinfo="pcre" +dep_fileinfo="" dep_wddx='xml' dep_xmlreader='dom' dep_xmlrpc='xml' dep_xsl='dom' -dep_snmp="$dep_spl spl snmp" -dep_opcache='pcre' +dep_snmp="snmp" +dep_opcache='' php=${PHP:-$(php-config --php-binary)} ext_dir=${EXTENSION_DIR:-$(php-config --extension-dir)} conf_dir=${CONFIG_DIR:-$(php-config --sysconfdir)/conf.d $(php-config --sysconfdir)/cli.d} -tmpini=$(mktemp) - -# poldek --sn ac-ready -u php-* -for ext in ${*:-$ext_dir/*.so}; do - [ -f $ext ] || continue - ext=${ext##*/}; ext=${ext%.so} - - deps=$(eval echo \$dep_$ext) - # add ext itself, if already not in list (spl case) - [[ $deps = *\ $ext\ * ]] || deps="$deps $ext" - - echo -n "$ext (deps: ${deps# })..." - - # special: opcache is listed as "Zend Opcache" - [ "$ext" = "opcache" ] && ext="zend opcache" - - grep -rlE '^(zend_)?extension=('$(echo "${deps# }" | tr ' ' '|')').so$' $conf_dir | LC_ALL=C sort | xargs cat > $tmpini - $php -n -d extension_dir=$ext_dir -c $tmpini -r "exit(extension_loaded('${ext}') ? 0 : 1);" - rc=$? - if [ $rc = 0 ]; then - echo OK - else - echo FAIL - echo "Failed config was:" - cat $tmpini - fi -done -rm -f $t + +test_deps() { + tmpini=$(mktemp) + + # poldek --sn ac-ready -u php-* + for ext in ${*:-$ext_dir/*.so}; do + [ -f $ext ] || continue + ext=${ext##*/}; ext=${ext%.so} + + deps=$(eval echo \$dep_$ext) + # add ext itself, if already not in list (spl case) + [[ $deps = *\ $ext\ * ]] || deps="$deps $ext" + + echo -n "$ext (deps: ${deps# })..." + + # special: opcache is listed as "Zend Opcache" + [ "$ext" = "opcache" ] && ext="zend opcache" + + grep -rlE '^(zend_)?extension=('$(echo "${deps# }" | tr ' ' '|')')$' $conf_dir | LC_ALL=C sort | xargs cat > $tmpini + $php -n -d extension_dir=$ext_dir -c $tmpini -r "exit(extension_loaded('${ext}') ? 0 : 1);" + rc=$? + if [ $rc = 0 ]; then + echo OK + else + echo FAIL + echo "Failed config was:" + cat $tmpini + fi + done +} + +_resolve_extension_deps() { + local name="$1" + + eval echo \$dep_$ext +} + +# Prints a load order (0-based integer) for the given extension name. Extension +# with lower load order should be loaded before exts with higher load order. +# It's based on number of dependencies of the extension (with exception for +# "imap"), which is flawed, but simple and good enough for now. +# +# _extension_load_order adopted from alpine linux: +# https://github.com/alpinelinux/aports/blob/v3.10.1/community/php7/APKBUILD#L639-L653 +_extension_load_order() { + local name="$1" + local deps=$(eval "echo \$dep_$name") + + case "$name" in + # XXX: This must be loaded after recode, even though it does + # not depend on it. So we must use this hack... + imap) echo 1;; + *) echo "${deps:=$(_resolve_extension_deps $name)}" | wc -w;; + esac +} + +generate_ini() { + local load_order + + rm -rf conf.d + install -d conf.d + for module in ${*:-$ext_dir/*.so}; do + [ -f $module ] || continue + extname=${module##*/}; extname=${extname%.so} + + ext=extension + # opcache.so is zend extension + nm $module | grep -q zend_extension_entry && ext=zend_extension + + load_order=$(_extension_load_order "$extname") + cat > conf.d/$(printf %02d $load_order)_$extname.ini <<-EOF + ; Enable $extname $ext module + $ext=$extname + EOF + done +} + +if [ -n "$GENERATE_INI" ]; then + generate_ini "$@" +else + test_deps "$@" +fi diff --git a/extension-shared-optional-dep.patch b/extension-shared-optional-dep.patch index be4597f..6925c72 100644 --- a/extension-shared-optional-dep.patch +++ b/extension-shared-optional-dep.patch @@ -1,5 +1,5 @@ ---- 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 +--- php-5.2.11/build/php.m4~ 2009-09-21 22:31:13.000000000 +0300 ++++ php-5.2.11/build/php.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__) diff --git a/fix-test-run.patch b/fix-test-run.patch index bd3c3d7..01742c4 100644 --- a/fix-test-run.patch +++ b/fix-test-run.patch @@ -1,19 +1,17 @@ --- php-5.4.0alpha2/configure.ac~ 2011-08-07 12:43:31.000000000 +0300 +++ php-5.4.0alpha2/configure.ac 2011-08-07 12:44:11.495394662 +0300 -@@ -1271,6 +1271,11 @@ +@@ -1271,6 +1271,9 @@ ;; esac -+# shift so that pcre, spl, ... are loaded first ++# shift so that extensions like xml 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_OLD(PHP_INSTALLED_SAPIS) PHP_SUBST(PHP_EXECUTABLE) ---- php-5.5.11/Makefile.global 2014-04-27 15:05:38.963814051 +0300 -+++ php-5.5.11/Makefile.global 2014-04-27 15:09:54.438443707 +0300 +--- php-5.5.11/build/Makefile.global 2014-04-27 15:05:38.963814051 +0300 ++++ php-5.5.11/build/Makefile.global 2014-04-27 15:09:54.438443707 +0300 @@ -81,8 +81,15 @@ done; \ fi @@ -31,13 +29,12 @@ if test "x$(PHP_MODULES)" != "x"; then \ for i in $(PHP_MODULES)""; do \ . $$i; $(top_srcdir)/build/shtool echo -n -- " -d extension=$$dlname"; \ -@@ -111,7 +118,10 @@ +@@ -111,7 +118,9 @@ 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); \ TEST_RESULT_EXIT_CODE=$$?; \ diff --git a/intl-stdc++.patch b/intl-stdc++.patch index f762c9b..7c18064 100644 --- a/intl-stdc++.patch +++ b/intl-stdc++.patch @@ -4,8 +4,8 @@ it's needed for ext/intl but it requires icu which already links with stdc++ so just omit PHP_ADD_LIBRARY(stdc++) ---- php-7.0.6/acinclude.m4~ 2016-05-16 18:31:11.000000000 +0300 -+++ php-7.0.6/acinclude.m4 2016-05-16 18:50:34.614991634 +0300 +--- php-7.0.6/build/php.m4~ 2016-05-16 18:31:11.000000000 +0300 ++++ php-7.0.6/build/php.m4 2016-05-16 18:50:34.614991634 +0300 @@ -762,7 +762,6 @@ if test -z "$php_cxx_done"; then AC_PROG_CXX diff --git a/mcrypt-libs.patch b/mcrypt-libs.patch deleted file mode 100644 index 2bc029c..0000000 --- a/mcrypt-libs.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- 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) diff --git a/milter.patch b/milter.patch deleted file mode 100644 index 5ed3573..0000000 --- a/milter.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- php-5.6.0RC4/sapi/milter/config.m4~ 2014-08-14 03:54:13.000000000 +0300 -+++ php-5.6.0RC4/sapi/milter/config.m4 2014-08-21 19:57:21.584244904 +0300 -@@ -6,18 +6,13 @@ - [ --with-milter[=DIR] Build PHP as Milter application], no, no) - - if test "$PHP_MILTER" != "no"; then -- if test "$PHP_MILTER" = "yes"; then -- if test -f /usr/lib/libmilter.a ; then -- MILTERPATH=/usr/lib -- else -- if test -f /usr/lib/libmilter/libmilter.a ; then -- MILTERPATH=/usr/lib/libmilter -- else -- AC_MSG_ERROR([Unable to find libmilter.a]) -- fi -- fi -- else -- MILTERPATH=$PHP_MILTER -+ for i in $PHP_MILTER /usr/lib/libmilter /usr/local /usr; do -+ test -f $i/$PHP_LIBDIR/libmilter.a && MILTERPATH=$i/$PHP_LIBDIR && break -+ test -f $i/libmilter.a && MILTERPATH=$i && break -+ done -+ -+ if test -z "$MILTERPATH"; then -+ AC_MSG_ERROR([Unable to find libmilter.a]) - fi - - SAPI_MILTER_PATH=sapi/milter/php-milter diff --git a/mysqlnd-ssl.patch b/mysqlnd-ssl.patch deleted file mode 100644 index 3157280..0000000 --- a/mysqlnd-ssl.patch +++ /dev/null @@ -1,24 +0,0 @@ -link mysqlnd.so with openssl if enabled - ---- php-5.6.1/ext/mysqlnd/config9.m4~ 2014-10-01 12:17:38.000000000 +0300 -+++ php-5.6.1/ext/mysqlnd/config9.m4 2014-10-07 20:19:44.653070295 +0300 -@@ -34,10 +34,17 @@ - test -z "$PHP_OPENSSL" && PHP_OPENSSL=no - - if test "$PHP_OPENSSL" != "no" || test "$PHP_OPENSSL_DIR" != "no"; then -- AC_CHECK_LIB(ssl, DSA_get_default_method, AC_DEFINE(HAVE_DSA_DEFAULT_METHOD, 1, [OpenSSL 0.9.7 or later])) -- AC_CHECK_LIB(crypto, X509_free, AC_DEFINE(HAVE_DSA_DEFAULT_METHOD, 1, [OpenSSL 0.9.7 or later])) -+ AC_CHECK_LIB(ssl, DSA_get_default_method, [ -+ AC_DEFINE(HAVE_DSA_DEFAULT_METHOD, 1, [OpenSSL 0.9.7 or later]) -+ PHP_ADD_EXTENSION_DEP(mysqlnd, ssl) -+ ]) -+ AC_CHECK_LIB(crypto, X509_free, [ -+ AC_DEFINE(HAVE_DSA_DEFAULT_METHOD, 1, [OpenSSL 0.9.7 or later]) -+ PHP_ADD_EXTENSION_DEP(mysqlnd, crypto) -+ ]) - - PHP_SETUP_OPENSSL(MYSQLND_SHARED_LIBADD, [AC_DEFINE(MYSQLND_HAVE_SSL,1,[Enable mysqlnd code that uses OpenSSL directly])]) -+ - fi - - mysqlnd_sources="$mysqlnd_base_sources $mysqlnd_ps_sources" diff --git a/opcache.ini b/opcache.ini index 16a3cff..b2931f6 100644 --- a/opcache.ini +++ b/opcache.ini @@ -1,6 +1,4 @@ -; Enable opcache zend extension module -zend_extension=opcache.so - +[opcache] ; Determines if Zend OPCache is enabled ;opcache.enable=1 @@ -42,18 +40,13 @@ zend_extension=opcache.so ; size of the optimized code. ;opcache.save_comments=1 -; If enabled, a fast shutdown sequence is used for the accelerated code -; Depending on the used Memory Manager this may cause some incompatibilities. -;opcache.fast_shutdown=0 - ; Allow file existence override (file_exists, etc.) performance feature. ;opcache.enable_file_override=0 ; A bitmask, where each bit enables or disables the appropriate OPcache ; passes -;opcache.optimization_level=0xffffffff +;opcache.optimization_level=0x7FFFBFFF -;opcache.inherited_hack=1 ;opcache.dups_fix=0 ; The location of the OPcache blacklist file (wildcards allowed). @@ -102,6 +95,10 @@ zend_extension=opcache.so ; errors. ;opcache.mmap_base= +; Facilitates multiple OPcache instances per user (for Windows only). All PHP +; processes with the same cache ID and user share an OPcache instance. +;opcache.cache_id= + ; Enables and sets the second level cache directory. ; It should improve performance when SHM memory is full, at server restart or ; SHM reset. The default "" disables file based caching. @@ -127,3 +124,25 @@ zend_extension=opcache.so ; Prevent name collisions in chroot'ed environment. ;opcache.validate_root=0 + +; If specified, it produces opcode dumps for debugging different stages of +; optimizations. +;opcache.opt_debug_level=0 + +; Specifies a PHP script that is going to be compiled and executed at server +; start-up. +; http://php.net/opcache.preload +;opcache.preload= + +; Preloading code as root is not allowed for security reasons. This directive +; facilitates to let the preloading to be run as another user. +; http://php.net/opcache.preload_user +;opcache.preload_user= + +; Prevents caching files that are less than this number of seconds old. It +; protects from caching of incompletely updated files. In case all file updates +; on your site are atomic, you may increase performance by setting it to "0". +;opcache.file_update_protection=2 + +; Absolute path used to store shared lockfiles (for *nix only). +;opcache.lockfile_path=/tmp diff --git a/pcre-shared.patch b/pcre-shared.patch deleted file mode 100644 index c1b2627..0000000 --- a/pcre-shared.patch +++ /dev/null @@ -1,180 +0,0 @@ -diff -urN php-7.3.12.orig/ext/pcre/config0.m4 php-7.3.12/ext/pcre/config0.m4 ---- php-7.3.12.orig/ext/pcre/config0.m4 2019-12-12 21:43:24.775000000 +0100 -+++ php-7.3.12/ext/pcre/config0.m4 2019-12-12 21:43:36.336000000 +0100 -@@ -84,8 +84,9 @@ - ]) - fi - -- PHP_NEW_EXTENSION(pcre, php_pcre.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) -+ PHP_NEW_EXTENSION(pcre, php_pcre.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) - PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h]) -+ EXTRA_LIBS="$EXTRA_LIBS -lpcre2-8" - else - AC_MSG_CHECKING([for PCRE library to use]) - AC_MSG_RESULT([bundled]) -diff -urN php-7.3.12.orig/ext/pcre/php_pcre.c php-7.3.12/ext/pcre/php_pcre.c ---- php-7.3.12.orig/ext/pcre/php_pcre.c 2019-12-12 21:43:24.775000000 +0100 -+++ php-7.3.12/ext/pcre/php_pcre.c 2019-12-12 21:43:36.339000000 +0100 -@@ -19,6 +19,9 @@ - #include "php.h" - #include "php_ini.h" - #include "php_globals.h" -+#if COMPILE_DL_PCRE -+#define COMPILE_DL_PCRE_NOREDIRECT -+#endif - #include "php_pcre.h" - #include "ext/standard/info.h" - #include "ext/standard/basic_functions.h" -@@ -290,6 +293,17 @@ - pcre2_set_match_limit(mctx, (uint32_t)PCRE_G(backtrack_limit)); - } - -+#if COMPILE_DL_PCRE -+ pcre_get_compiled_regex_p = pcre_get_compiled_regex; -+ pcre_get_compiled_regex_cache_p = pcre_get_compiled_regex_cache; -+ php_pcre_replace_impl_p = php_pcre_replace_impl; -+ php_pcre_match_impl_p = php_pcre_match_impl; -+ php_pcre_split_impl_p = php_pcre_split_impl; -+ php_pcre_create_match_data_p = php_pcre_create_match_data; -+ php_pcre_free_match_data_p = php_pcre_free_match_data; -+ php_pcre_mctx_p = php_pcre_mctx; -+#endif -+ - return SUCCESS; - }/*}}}*/ - -diff -urN php-7.3.12.orig/ext/pcre/php_pcre.h php-7.3.12/ext/pcre/php_pcre.h ---- php-7.3.12.orig/ext/pcre/php_pcre.h 2019-12-12 21:43:24.777000000 +0100 -+++ php-7.3.12/ext/pcre/php_pcre.h 2019-12-12 21:45:10.506000000 +0100 -@@ -31,7 +31,35 @@ - #include - #endif - -+#if !defined(COMPILE_DL_PCRE_NOREDIRECT) -+#define pcre_get_compiled_regex (*pcre_get_compiled_regex_p) -+#define pcre_get_compiled_regex_cache (*pcre_get_compiled_regex_cache_p) -+#define php_pcre_replace_impl (*php_pcre_replace_impl_p) -+#define php_pcre_match_impl (*php_pcre_match_impl_p) -+#define php_pcre_split_impl (*php_pcre_split_impl_p) -+#define php_pcre_create_match_data (*php_pcre_create_match_data_p) -+#define php_pcre_free_match_data (*php_pcre_free_match_data_p) -+#define php_pcre_mctx (*php_pcre_mctx_p) -+#if !defined(COMPILE_DL_PCRE_NOEXTERN) -+# define PCRE_EXTERN extern -+#else -+# define PCRE_EXTERN -+#endif -+#else -+// for pcre.c -+#define PCRE_EXTERN -+extern void *pcre_get_compiled_regex_p; -+extern void *pcre_get_compiled_regex_cache_p; -+extern void *php_pcre_replace_impl_p; -+extern void *php_pcre_match_impl_p; -+extern void *php_pcre_split_impl_p; -+extern void *php_pcre_create_match_data_p; -+extern void *php_pcre_free_match_data_p; -+extern void *php_pcre_mctx_p; -+#endif -+ - PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count); -+PCRE_EXTERN - PHPAPI pcre2_code* pcre_get_compiled_regex(zend_string *regex, uint32_t *capture_count, uint32_t *options); - PHPAPI pcre2_code* pcre_get_compiled_regex_ex(zend_string *regex, uint32_t *capture_count, uint32_t *preg_options, uint32_t *coptions); - -@@ -43,21 +71,26 @@ - - typedef struct _pcre_cache_entry pcre_cache_entry; - -+PCRE_EXTERN - PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex); - PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, int locale_aware); - -+PCRE_EXTERN - PHPAPI void php_pcre_match_impl( pcre_cache_entry *pce, char *subject, size_t subject_len, zval *return_value, - zval *subpats, int global, int use_flags, zend_long flags, zend_off_t start_offset); - -+PCRE_EXTERN - PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str, - size_t limit, size_t *replace_count); - -+PCRE_EXTERN - PHPAPI void php_pcre_split_impl( pcre_cache_entry *pce, zend_string *subject_str, zval *return_value, - zend_long limit_val, zend_long flags); - - PHPAPI void php_pcre_grep_impl( pcre_cache_entry *pce, zval *input, zval *return_value, - zend_long flags); - -+PCRE_EXTERN - PHPAPI pcre2_match_context *php_pcre_mctx(void); - PHPAPI pcre2_general_context *php_pcre_gctx(void); - PHPAPI pcre2_compile_context *php_pcre_cctx(void); -@@ -65,7 +98,9 @@ - PHPAPI void php_pcre_pce_decref(pcre_cache_entry *); - PHPAPI pcre2_code *php_pcre_pce_re(pcre_cache_entry *); - /* capture_count can be ignored, re is required. */ -+PCRE_EXTERN - PHPAPI pcre2_match_data *php_pcre_create_match_data(uint32_t, pcre2_code *); -+PCRE_EXTERN - PHPAPI void php_pcre_free_match_data(pcre2_match_data *); - - ZEND_BEGIN_MODULE_GLOBALS(pcre) -diff -urN php-7.3.12.orig/ext/phar/Makefile.frag php-7.3.12/ext/phar/Makefile.frag ---- php-7.3.12.orig/ext/phar/Makefile.frag 2019-12-12 21:43:24.654000000 +0100 -+++ php-7.3.12/ext/phar/Makefile.frag 2019-12-12 21:43:36.358000000 +0100 -@@ -14,7 +14,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 spl 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; \ -diff -urN php-7.3.12.orig/ext/standard/basic_functions.c php-7.3.12/ext/standard/basic_functions.c ---- php-7.3.12.orig/ext/standard/basic_functions.c 2019-12-12 21:43:24.765000000 +0100 -+++ php-7.3.12/ext/standard/basic_functions.c 2019-12-12 21:43:36.361000000 +0100 -@@ -112,6 +112,18 @@ - PHPAPI php_basic_globals basic_globals; - #endif - -+#if COMPILE_DL_PCRE -+// Declare the pointers in core library -+void *pcre_get_compiled_regex_p; -+void *pcre_get_compiled_regex_cache_p; -+void *php_pcre_replace_impl_p; -+void *php_pcre_match_impl_p; -+void *php_pcre_split_impl_p; -+void *php_pcre_create_match_data_p; -+void *php_pcre_free_match_data_p; -+void *php_pcre_mctx_p; -+#endif -+ - #include "php_fopen_wrappers.h" - #include "streamsfuncs.h" - -diff -urN php-7.3.12.orig/main/php_ini.c php-7.3.12/main/php_ini.c ---- php-7.3.12.orig/main/php_ini.c 2019-12-12 21:43:24.549000000 +0100 -+++ php-7.3.12/main/php_ini.c 2019-12-12 21:43:36.364000000 +0100 -@@ -807,8 +807,8 @@ - */ - void php_ini_register_extensions(void) - { -- zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb); - zend_llist_apply(&extension_lists.functions, php_load_php_extension_cb); -+ zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb); - - zend_llist_destroy(&extension_lists.engine); - zend_llist_destroy(&extension_lists.functions); -diff -urN php-7.3.12.orig/sapi/cli/tests/018.phpt php-7.3.12/sapi/cli/tests/018.phpt ---- php-7.3.12.orig/sapi/cli/tests/018.phpt 2019-12-12 21:43:24.534000000 +0100 -+++ php-7.3.12/sapi/cli/tests/018.phpt 2019-12-12 21:43:36.364000000 +0100 -@@ -20,8 +20,6 @@ - --EXPECTF-- - [PHP Modules] - %a --pcre --%a - - [Zend Modules] - %aDone diff --git a/phar-hash-shared.patch b/phar-hash-shared.patch deleted file mode 100644 index 621fe6d..0000000 --- a/phar-hash-shared.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- php-7.0.0RC6/ext/phar/config.m4 2015-11-17 19:13:50.877662712 +0200 -+++ php-7.0.0RC6/ext/phar/config.m4 2015-11-20 12:51:24.088185045 +0200 -@@ -7,13 +7,13 @@ - if test "$PHP_PHAR" != "no"; then - PHP_NEW_EXTENSION(phar, util.c tar.c zip.c stream.c func_interceptors.c dirstream.c phar.c phar_object.c phar_path_check.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) - AC_MSG_CHECKING([for phar openssl support]) -- if test "$PHP_HASH_SHARED" != "yes"; then -- if test "$PHP_HASH" != "no"; then -+dnl if test "$PHP_HASH_SHARED" != "yes"; then -+dnl if test "$PHP_HASH" != "no"; then - AC_DEFINE(PHAR_HASH_OK,1,[ ]) -- fi -- else -- AC_MSG_WARN([Phar: sha256/sha512 signature support disabled if ext/hash is built shared]) -- fi -+dnl fi -+dnl else -+dnl AC_MSG_WARN([Phar: sha256/sha512 signature support disabled if ext/hash is built shared]) -+dnl fi - if test "$PHP_OPENSSL_SHARED" = "yes"; then - AC_MSG_RESULT([no (shared openssl)]) - else ---- php-7.0.0RC7/ext/phar/Makefile.frag~ 2015-11-23 11:06:31.000000000 +0200 -+++ php-7.0.0RC7/ext/phar/Makefile.frag 2015-11-23 11:15:36.452443959 +0200 -@@ -9,7 +9,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 pcre spl bz2 zlib phar; do \ -+ for i in pcre spl bz2 zlib hash 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; \ diff --git a/php-both-apxs.patch b/php-both-apxs.patch index 8e7bd89..3cba2ae 100644 --- a/php-both-apxs.patch +++ b/php-both-apxs.patch @@ -1,5 +1,5 @@ ---- 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 +--- php-5.2.4/build/Makefile.global~ 2007-08-31 19:35:54.000000000 +0300 ++++ php-5.2.4/build/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 diff --git a/php-build_modules.patch b/php-build_modules.patch deleted file mode 100644 index cf222ec..0000000 --- a/php-build_modules.patch +++ /dev/null @@ -1,9 +0,0 @@ -diff -Naur php-4.1.2.orig/ext/skeleton/create_stubs php-4.1.2/ext/skeleton/create_stubs ---- php-4.1.2.orig/ext/skeleton/create_stubs Fri May 31 11:50:08 2002 -+++ php-4.1.2/ext/skeleton/create_stubs Fri May 31 11:52:00 2002 -@@ -1,4 +1,4 @@ --#!/usr/bin/awk -f -+#!/bin/awk -f - - function gobble(s, x) - { diff --git a/php-cgi-fcgi.ini b/php-cgi-fcgi.ini index 809c7d3..bae4609 100644 --- a/php-cgi-fcgi.ini +++ b/php-cgi-fcgi.ini @@ -8,41 +8,65 @@ ; 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 +; 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. -; cgi.nph = 1 +; 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. -; cgi.redirect_status_env = ; +; 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 it's paths to conform to the spec. A 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 +; if cgi.discard_path is enabled, the PHP CGI binary can safely be placed outside +; of the web tree and people will not be able to circumvent .htaccess security. +; http://php.net/cgi.dicard-path +;cgi.discard_path=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 +; use when sending HTTP response code. If set to 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 +; cgi.check_shebang_line controls whether CGI PHP checks for line starting with #! +; (shebang) at the top of the running script. This line might be needed if the +; script support running both as stand-alone script and via PHP CGI<. PHP in CGI +; mode skips this line and ignores its content if this directive is turned on. +; http://php.net/cgi.check-shebang-line +;cgi.check_shebang_line=1 + [Session] session.save_path = /tmp ; argument passed to save_handler ; in the case of files, this is the diff --git a/php-filter-shared.patch b/php-filter-shared.patch deleted file mode 100644 index 3983c3f..0000000 --- a/php-filter-shared.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- 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 diff --git a/php-fpm-config.patch b/php-fpm-config.patch index da235fc..c020558 100644 --- a/php-fpm-config.patch +++ b/php-fpm-config.patch @@ -70,8 +70,8 @@ ths = document.getElementsByTagName("th"); for (var i=0; i aclocal.m4) -+ (cd "$builddir/build" && cat ../acinclude.m4 $LIBTOOL_FILES > ../aclocal.m4) - } - - phpize_replace_prefix() diff --git a/php-link-libs.patch b/php-link-libs.patch index e65166a..fb73edd 100644 --- a/php-link-libs.patch +++ b/php-link-libs.patch @@ -1,16 +1,6 @@ ---- php-4.3.0/configure.ac.orig Fri Dec 27 05:07:18 2002 -+++ php-4.3.0/configure.ac 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 -@@ -1834,18 +1834,18 @@ +--- php-7.3.0beta3/build/php.m4~ 2018-08-28 13:26:36.000000000 +0300 ++++ php-7.3.0beta3/build/php.m4 2018-09-05 18:56:49.744106256 +0300 +@@ -1829,18 +1829,18 @@ dnl Wrapper for AC_CHECK_LIB dnl AC_DEFUN([PHP_CHECK_LIBRARY], [ diff --git a/php-nohttpd.patch b/php-nohttpd.patch index 8a68bc7..8c5b05b 100644 --- a/php-nohttpd.patch +++ b/php-nohttpd.patch @@ -1,14 +1,11 @@ ---- php-5.5.2/sapi/apache2handler/config.m4~ 2013-08-15 23:42:04.000000000 +0300 -+++ php-5.5.2/sapi/apache2handler/config.m4 2013-08-18 15:13:02.728903161 +0300 -@@ -60,9 +60,9 @@ +--- php-7.4.0alpha3/sapi/apache2handler/config.m4~ 2019-07-09 10:39:56.000000000 +0300 ++++ php-7.4.0alpha3/sapi/apache2handler/config.m4 2019-07-14 23:54:57.845267916 +0300 +@@ -59,7 +59,7 @@ - # Test that we're trying to configure with apache 2.x + dnl 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 appropriate 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 +- if test "$APACHE_VERSION" -lt 2000044; then ++ if 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 diff --git a/php-pear.patch b/php-pear.patch deleted file mode 100644 index 2772cd1..0000000 --- a/php-pear.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- php-7.3.0beta3/configure.ac~ 2018-09-05 19:02:49.000000000 +0300 -+++ php-7.3.0beta3/configure.ac 2018-09-05 19:04:13.237533903 +0300 -@@ -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) -@@ -1137,19 +1137,6 @@ - --without-pear Do not install PEAR], DEFAULT, yes) - - if test "$PHP_PEAR" != "no"; then -- -- dnl -- dnl PEAR dependencies -- 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 -- -- if test "$pear_error_msg"; then -- AC_MSG_ERROR([$pear_error_msg]) -- fi -- - install_pear="install-pear" - PEAR_INSTALLDIR=$PHP_PEAR - ---- 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 diff --git a/php-sapi-ini-file.patch b/php-sapi-ini-file.patch index 0ed4d79..598be44 100644 --- a/php-sapi-ini-file.patch +++ b/php-sapi-ini-file.patch @@ -1,12 +1,36 @@ -to test which is main php.ini: +The ini loading order is in PLD (as of 7.4.0beta2): +- openat(AT_FDCWD, "/etc/php74/php-cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory) +- openat(AT_FDCWD, "/etc/php74/php.ini", O_RDONLY) = 4 +- openat(AT_FDCWD, "/etc/php74/conf.d", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 4 +- openat(AT_FDCWD, "/etc/php74/conf.d/00_curl.ini", O_RDONLY) = 4 +- openat(AT_FDCWD, "/etc/php74/conf.d/00_json.ini", O_RDONLY) = 4 +- openat(AT_FDCWD, "/etc/php74/conf.d/00_opcache.ini", O_RDONLY) = 4 +- openat(AT_FDCWD, "/etc/php74/conf.d/00_xml.ini", O_RDONLY) = 4 +- openat(AT_FDCWD, "/etc/php74/conf.d/opcache.ini", O_RDONLY) = 4 +- openat(AT_FDCWD, "/etc/php74/conf.d/timezone.ini", O_RDONLY) = 4 +- openat(AT_FDCWD, "/etc/php74/cli.d", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 4 +- openat(AT_FDCWD, "/etc/php74/cli.d/00_readline.ini", O_RDONLY) = 4 +- openat(AT_FDCWD, "/etc/php74/cli.d/php.ini", O_RDONLY) = 4 + +1. load php-.ini; if exists treat as main php.ini +2. load php.ini if php-.ini was not found +3. load conf.d/DD_*.ini to load extra extension and zend_extension lines +4. load conf.d/*.ini to load extra ini settings not involving loading extension +5. load .d same way as conf.d + +This allows minimal patch, but still allowing to have main php ini and sapi specific overrides + +To test which is main php.ini: $ php -r 'var_dump(array(get_cfg_var("cfg_file_path"),php_ini_loaded_file()));' https://github.com/pld-linux/php/commit/762ec2e ---- php-7.0.0RC6.orig/main/php_ini.c 2015-11-10 23:58:52.227101032 +0200 -+++ php-7.0.0RC6/main/php_ini.c 2015-11-11 00:01:43.502674750 +0200 -@@ -375,12 +375,19 @@ - } +diff --git a/main/php_ini.c b/main/php_ini.c +index d508c13b50..2cf28eb7f5 100644 +--- a/main/php_ini.c ++++ b/main/php_ini.c +@@ -410,6 +410,11 @@ static void php_load_zend_extension_cb(void *arg) { } + #endif /* }}} */ +static int php_csort(const struct dirent **a, const struct dirent **b) @@ -17,90 +41,7 @@ https://github.com/pld-linux/php/commit/762ec2e /* {{{ php_init_config */ int php_init_config(void) - { - char *php_ini_file_name = NULL; - char *php_ini_search_path = NULL; -+ // value for php_ini_loaded_file() to be stored into php_ini_opened_path -+ char *php_ini_loaded_file = NULL; - int php_ini_scanned_path_len; - char *open_basedir; - int free_ini_search_path = 0; -@@ -557,8 +564,26 @@ - } - } - } -+ /* 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, &opened_path); -+ if (fh.handle.fp) { -+ fh.filename = ZSTR_VAL(opened_path); -+ -+ // parse the ini file now -+ 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); -+ open_basedir = PG(open_basedir); -+ PG(open_basedir) = NULL; -+ fh.handle.fp = NULL; -+ -+ php_ini_loaded_file = estrdup(fh.filename); -+ fh.filename = NULL; -+ } -+ } - -- /* Otherwise search for php-%sapi-module-name%.ini file in search path */ -+ /* Also search for php-%sapi-module-name%.ini file in search path */ - if (!fh.handle.fp) { - const char *fmt = "php-%s.ini"; - char *ini_fname; -@@ -568,15 +593,8 @@ - if (fh.handle.fp) { - fh.filename = ZSTR_VAL(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, &opened_path); -- if (fh.handle.fp) { -- fh.filename = ZSTR_VAL(opened_path); -- } -- } -+ } - } - - if (free_ini_search_path) { -@@ -593,14 +611,28 @@ - - { - zval tmp; -+ // use main php.ini if loaded -+ // see https://github.com/pld-linux/php/commit/762ec2e -+ // test with: -+ // php -r 'var_dump(array(get_cfg_var("cfg_file_path"),php_ini_loaded_file()));' -+ if (php_ini_loaded_file) { -+ if (fh.filename) { -+ efree((char *)fh.filename); -+ } -+ fh.filename = php_ini_loaded_file; -+ } - - ZVAL_NEW_STR(&tmp, zend_string_init(fh.filename, strlen(fh.filename), 1)); - zend_hash_str_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path")-1, &tmp); - if (opened_path) { - zend_string_release_ex(opened_path, 0); -- } else { -+ } -+ -+ if (fh.filename) { - efree((char *)fh.filename); -+ fh.filename = NULL; - } -+ - php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp)); - } - } -@@ -624,13 +656,15 @@ +@@ -661,12 +666,14 @@ int php_init_config(void) zend_llist scanned_ini_list; zend_llist_element *element; int l, total_l = 0; @@ -109,7 +50,6 @@ https://github.com/pld-linux/php/commit/762ec2e int lenpath; zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1); - memset(&fh2, 0, sizeof(fh2)); - bufpath = estrdup(php_ini_scanned_path); + bufpath = emalloc(strlen(php_ini_scanned_path) + strlen(fmt) + strlen(sapi_module.name)); @@ -117,7 +57,7 @@ https://github.com/pld-linux/php/commit/762ec2e for (debpath = bufpath ; debpath ; debpath=endpath) { endpath = strchr(debpath, DEFAULT_DIR_SEPARATOR); if (endpath) { -@@ -643,7 +677,7 @@ +@@ -679,7 +686,7 @@ int php_init_config(void) } lenpath = (int)strlen(debpath); diff --git a/php-shared.patch b/php-shared.patch index 24c6848..ac15661 100644 --- a/php-shared.patch +++ b/php-shared.patch @@ -1,17 +1,17 @@ ---- php-7.0.0RC3/configure.ac~ 2015-09-26 14:55:35.000000000 +0300 -+++ php-7.0.0RC3/configure.ac 2015-09-26 15:13:29.581882625 +0300 -@@ -224,6 +224,9 @@ - dnl check for -R, etc. switch +--- php-src-PHP-7.4/configure.ac~ 2019-05-25 12:37:30.000000000 +0300 ++++ php-src-PHP-7.4/configure.ac 2019-05-26 10:07:36.385580763 +0300 +@@ -202,6 +202,9 @@ + dnl Check for -R, etc. switch. PHP_RUNPATH_SWITCH +dnl Always shared +PHP_BUILD_SHARED + - dnl Checks for some support/generator progs + dnl Checks for some support/generator progs. PHP_PROG_AWK - PHP_PROG_BISON ---- 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 + PHP_PROG_BISON([3.0.0]) +--- php-7.4.0RC3/build/Makefile.global~ 2019-10-04 16:11:24.000000000 +0300 ++++ php-7.4.0RC3/build/Makefile.global 2019-10-09 15:21:11.198544363 +0300 @@ -13,8 +13,12 @@ build-modules: $(PHP_MODULES) @@ -41,10 +41,10 @@ break; \ fi; \ done; \ ---- php-7.0.0beta1/sapi/cgi/config9.m4~ 2015-07-10 15:11:43.000000000 +0300 -+++ php-7.0.0beta1/sapi/cgi/config9.m4 2015-07-13 16:03:06.900955209 +0300 -@@ -64,7 +64,7 @@ - BUILD_CGI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_FASTCGI_OBJS:.lo=.o) \$(PHP_CGI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)" +--- php-7.4.0RC2/sapi/cgi/config9.m4~ 2019-09-17 19:37:54.000000000 +0300 ++++ php-7.4.0RC2/sapi/cgi/config9.m4 2019-09-20 13:43:03.654012130 +0300 +@@ -55,7 +55,7 @@ + BUILD_CGI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_FASTCGI_OBJS) \$(PHP_CGI_OBJS) \$(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_BINARY_OBJS) \$(PHP_FASTCGI_OBJS) \$(PHP_CGI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)" @@ -62,10 +62,10 @@ $(BUILD_CGI) install-cgi: $(SAPI_CGI_PATH) ---- php-5.4.0alpha2/sapi/cli/config.m4~ 2011-06-20 23:27:39.000000000 +0300 -+++ php-5.4.0alpha2/sapi/cli/config.m4 2011-08-01 10:34:01.072624745 +0300 -@@ -31,7 +31,7 @@ - BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_BINARY_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -Lnetware -lphp5lib -o \$(SAPI_CLI_PATH)" +--- php-7.4.0RC2/sapi/cli/config.m4~ 2019-09-17 19:37:55.000000000 +0300 ++++ php-7.4.0RC2/sapi/cli/config.m4 2019-09-20 13:44:29.124988912 +0300 +@@ -42,7 +42,7 @@ + BUILD_CLI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_CLI_OBJS) \$(PHP_FRAMEWORKS) \$(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_BINARY_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)" @@ -98,10 +98,10 @@ $(BUILD_PHPDBG) %.c: %.y ---- php-7.0.0RC3/sapi/phpdbg/config.m4~ 2015-09-16 15:49:38.000000000 +0300 -+++ php-7.0.0RC3/sapi/phpdbg/config.m4 2015-09-27 21:25:34.413134698 +0300 -@@ -40,7 +40,7 @@ - +--- php-7.4.0RC2/sapi/phpdbg/config.m4~ 2019-09-20 13:45:42.000000000 +0300 ++++ php-7.4.0RC2/sapi/phpdbg/config.m4 2019-09-20 13:53:08.504534283 +0300 +@@ -63,7 +63,7 @@ + BUILD_PHPDBG="\$(LIBTOOL) --mode=link \ \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \ - \$(PHP_GLOBAL_OBJS) \ @@ -128,14 +128,10 @@ $(BUILD_LITESPEED) install-litespeed: $(SAPI_LITESPEED_PATH) ---- php-7.0.0RC3/sapi/litespeed/config.m4~ 2015-09-16 15:49:38.000000000 +0300 -+++ php-7.0.0RC3/sapi/litespeed/config.m4 2015-09-27 21:27:36.182790123 +0300 -@@ -17,10 +17,10 @@ - ;; - *cygwin*) - SAPI_LITESPEED_PATH=sapi/litespeed/php.exe -- BUILD_LITESPEED="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_LITESPEED_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)" -+ BUILD_LITESPEED="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) libphp_common.la \$(PHP_BINARY_OBJS) \$(PHP_LITESPEED_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)" +--- php-7.4.0RC2/sapi/litespeed/config.m4~ 2019-09-17 19:37:55.000000000 +0300 ++++ php-7.4.0RC2/sapi/litespeed/config.m4 2019-09-20 13:55:12.834143941 +0300 +@@ -18,7 +18,7 @@ + BUILD_LITESPEED="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_LITESPEED_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)" ;; *) - BUILD_LITESPEED="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_LITESPEED_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)" @@ -143,3 +139,24 @@ ;; esac +--- php-7.4.0RC2/sapi/fpm/config.m4~ 2019-09-17 19:37:55.000000000 +0300 ++++ php-7.4.0RC2/sapi/fpm/config.m4 2019-09-20 13:56:34.351592384 +0300 +@@ -660,7 +660,7 @@ + BUILD_FPM="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_FASTCGI_OBJS) \$(PHP_FPM_OBJS) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(FPM_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_BINARY_OBJS) \$(PHP_FASTCGI_OBJS) \$(PHP_FPM_OBJS) \$(EXTRA_LIBS) \$(FPM_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_BINARY_OBJS) \$(PHP_FASTCGI_OBJS) \$(PHP_FPM_OBJS) \$(EXTRA_LIBS) \$(FPM_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)" + ;; + esac + +--- php-7.0.0beta1/sapi/fpm/Makefile.frag~ 2015-07-15 13:54:11.000000000 +0300 ++++ php-7.0.0beta1/sapi/fpm/Makefile.frag 2015-07-15 13:56:12.116885111 +0300 +@@ -1,6 +1,6 @@ + fpm: $(SAPI_FPM_PATH) + +-$(SAPI_FPM_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_FASTCGI_OBJS) $(PHP_FPM_OBJS) ++$(SAPI_FPM_PATH): libphp_common.la $(PHP_BINARY_OBJS) $(PHP_FASTCGI_OBJS) $(PHP_FPM_OBJS) $(SAPI_EXTRA_DEPS) + $(BUILD_FPM) + + install-fpm: $(SAPI_FPM_PATH) diff --git a/php-stupidapache_version.patch b/php-stupidapache_version.patch index 100ec4f..ab1d8e0 100644 --- a/php-stupidapache_version.patch +++ b/php-stupidapache_version.patch @@ -1,5 +1,5 @@ ---- php-5.4.0alpha2/acinclude.m4 2011-08-07 21:13:21.581133944 +0300 -+++ php-5.4.0alpha2/acinclude.m4 2011-08-07 21:10:21.766717150 +0300 +--- php-5.4.0alpha2/build/php.m4 2011-08-07 21:13:21.581133944 +0300 ++++ php-5.4.0alpha2/build/php.m4 2011-08-07 21:10:21.766717150 +0300 @@ -2607,7 +2609,14 @@ dnl version for apache1/2. dnl diff --git a/php-use-prog_sendmail.patch b/php-use-prog_sendmail.patch index 5f4af4e..161e446 100644 --- a/php-use-prog_sendmail.patch +++ b/php-use-prog_sendmail.patch @@ -1,5 +1,5 @@ ---- 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 +--- php-5.2.6/build/php.m4~ 2008-10-15 13:44:25.000000000 +0300 ++++ php-5.2.6/build/php.m4 2008-10-15 13:55:05.359850285 +0300 @@ -2037,8 +2037,10 @@ dnl Search for the sendmail binary dnl diff --git a/php.spec b/php.spec index 17c15c8..f8e709e 100644 --- a/php.spec +++ b/php.spec @@ -12,7 +12,6 @@ %bcond_without cgi # disable CGI/FCGI SAPI %bcond_without fpm # disable FPM SAPI %bcond_without litespeed # build litespeed SAPI -%bcond_with milter # disable Milter SAPI %bcond_without phpdbg # disable phpdbg SAPI # - Extensions %bcond_without bcmath # without bcmath extension module @@ -24,16 +23,15 @@ %bcond_without dom # without DOM extension module %bcond_without enchant # without Enchant extension module %bcond_without exif # without EXIF extension module +%bcond_without ffi # without FFI extension module %bcond_without fileinfo # without fileinfo extension module %bcond_without filter # without filter extension module %bcond_without ftp # without FTP extension module %bcond_without gd # without GD extension module %bcond_without gettext # without gettext extension module %bcond_without gmp # without gmp extension module -%bcond_without hash # without hash extension module %bcond_without iconv # without iconv extension module %bcond_without imap # without IMAP extension module -%bcond_without interbase # without InterBase extension module %bcond_without intl # without Intl extension module %bcond_without json # without json extension module %bcond_without ldap # without LDAP extension module @@ -46,24 +44,26 @@ %bcond_without opcache # without Enable Zend OPcache extension support %bcond_without openssl # without OpenSSL support and OpenSSL extension (module) %bcond_without pcntl # without pcntl extension module -%bcond_without pcre # without PCRE extension module +%bcond_without pcre_jit # PCRE JIT %bcond_without pdo # without PDO extension module %bcond_without pdo_dblib # without PDO dblib extension module +%bcond_without pdo_firebird # without PDO Firebird extension module %bcond_without pdo_mysql # without PDO MySQL extension module +%bcond_without pdo_oci # without PDO oci extension module +%bcond_without pdo_odbc # without PDO ODBC extension module +%bcond_without pdo_pgsql # without PDO pgsql 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 posix # without POSIX extension module %bcond_without pspell # without pspell extension module %bcond_without readline # without readline extension module -%bcond_without recode # without recode extension module %bcond_without session # without session extension module %bcond_without snmp # without SNMP extension module %bcond_without sodium # without sodium extension module %bcond_without sqlite2 # without SQLite extension module %bcond_without sqlite3 # without SQLite3 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 xsl # without xsl extension module %bcond_without zip # without zip extension module @@ -75,7 +75,6 @@ %bcond_without system_gd # system gd %bcond_without webp # Without WebP support in GD extension (imagecreatefromwebp) -%define apxs1 /usr/sbin/apxs1 %define apxs2 /usr/sbin/apxs # disable all sapis @@ -90,14 +89,16 @@ %undefine with_mm %endif -# milter requires ZTS -%if %{with milter} && %{without zts} -%undefine with_milter +%if %{without odbc} +%undefine with_pdo_odbc %endif -%ifnarch %{ix86} %{x8664} x32 sparc sparcv9 alpha -# ppc disabled (broken on th-ppc) -%undefine with_interbase +%if %{without pgsql} +%undefine with_pdo_pgsql +%endif + +%if %{without oci} +%undefine with_pdo_oci %endif %ifnarch %{ix86} %{x8664} x32 @@ -105,13 +106,18 @@ %undefine with_fpm %endif -# filter depends on pcre -%if %{without pcre} -%undefine with_filter +%if %{without pdo} +%undefine with_pdo_dblib +%undefine with_pdo_firebird +%undefine with_pdo_mysql +%undefine with_pdo_oci +%undefine with_pdo_odbc +%undefine with_pdo_pgsql +%undefine with_pdo_sqlite %endif %define orgname php -%define php_suffix 73 +%define php_suffix 74 Summary: PHP: Hypertext Preprocessor Summary(fr.UTF-8): Le langage de script embarque-HTML PHP Summary(pl.UTF-8): Język skryptowy PHP @@ -119,8 +125,8 @@ Summary(pt_BR.UTF-8): A linguagem de script PHP Summary(ru.UTF-8): PHP Версии 7 - язык препроцессирования HTML-файлов, выполняемый на сервере Summary(uk.UTF-8): PHP Версії 7 - мова препроцесування HTML-файлів, виконувана на сервері Name: %{orgname}%{php_suffix} -Version: 7.3.12 -Release: 1 +Version: 7.4.0 +Release: 0.1 Epoch: 4 # All files licensed under PHP version 3.01, except # Zend is licensed under Zend @@ -128,7 +134,7 @@ Epoch: 4 License: PHP 3.01 and Zend and BSD Group: Libraries Source0: http://php.net/distributions/%{orgname}-%{version}.tar.xz -# Source0-md5: e52a0dc6e7d94024989d0a3746070487 +# Source0-md5: c2ab075e03e4757014196640c24dad25 Source1: opcache.ini Source2: %{orgname}-mod_php.conf Source3: %{orgname}-cgi-fcgi.ini @@ -143,9 +149,7 @@ Patch0: %{orgname}-shared.patch Patch1: %{orgname}-tld.patch Patch3: %{orgname}-link-libs.patch Patch4: intl-stdc++.patch -Patch5: %{orgname}-filter-shared.patch Patch7: %{orgname}-sapi-ini-file.patch -Patch8: milter.patch Patch9: libtool-tag.patch Patch10: %{orgname}-ini.patch Patch11: embed.patch @@ -157,36 +161,29 @@ Patch22: %{orgname}-both-apxs.patch Patch23: %{orgname}-paths.patch Patch24: %{orgname}-zlib-for-getimagesize.patch Patch25: %{orgname}-stupidapache_version.patch -Patch26: %{orgname}-pear.patch Patch27: %{orgname}-config-dir.patch Patch29: %{orgname}-fcgi-graceful.patch Patch31: %{orgname}-fcgi-error_log-no-newlines.patch -Patch34: %{orgname}-libtool.patch Patch37: %{orgname}-mysqli-charsetphpini.patch Patch38: %{orgname}-pdo_mysql-charsetphpini.patch Patch39: %{orgname}-use-prog_sendmail.patch Patch41: %{orgname}-fpm-config.patch -Patch42: %{orgname}-fpm-shared.patch Patch43: %{orgname}-silent-session-cleanup.patch Patch44: %{orgname}-include_path.patch Patch50: extension-shared-optional-dep.patch -Patch51: spl-shared.patch -Patch52: pcre-shared.patch Patch53: fix-test-run.patch Patch55: bug-52078-fileinode.patch Patch59: %{orgname}-systzdata.patch Patch66: php-db.patch Patch67: mysql-lib-ver-mismatch.patch Patch69: fpm-conf-split.patch -Patch70: mysqlnd-ssl.patch Patch71: libdb-info.patch -Patch72: phar-hash-shared.patch URL: http://php.net/ -%{?with_interbase:%{!?with_interbase_inst:BuildRequires: Firebird-devel >= 1.0.2.908-2}} +%{?with_firebird:%{!?with_interbase_inst:BuildRequires: Firebird-devel >= 1.0.2.908-2}} %{?with_pspell:BuildRequires: aspell-devel >= 2:0.50.0} BuildRequires: autoconf >= 2.59 BuildRequires: automake >= 1.4d -BuildRequires: bison +BuildRequires: bison >= 3.0.0 BuildRequires: bzip2-devel >= 1.0.0 %{?with_curl:BuildRequires: curl-devel >= 7.15.5} BuildRequires: cyrus-sasl-devel >= 2 @@ -195,6 +192,7 @@ BuildRequires: elfutils-devel %{?with_enchant:BuildRequires: enchant-devel >= 1.1.3} %{?with_kerberos5:BuildRequires: heimdal-devel} %{?with_argon2:BuildRequires: libargon2-devel >= 20161029} +%{?with_ffi:BuildRequires: libffi-devel} %{?with_sodium:BuildRequires: libsodium-devel >= 1.0.8} %if %{with pdo_dblib} BuildRequires: freetds-devel >= 0.82 @@ -208,13 +206,13 @@ BuildRequires: gmp-devel >= 4.2 %{?with_imap:BuildRequires: imap-devel >= 1:2007e-2} %{?with_gcov:BuildRequires: lcov} %{?with_fpm:BuildRequires: libapparmor-devel} -%{?with_intl:BuildRequires: libicu-devel >= 4.4} +%{?with_intl:BuildRequires: libicu-devel >= 50.1} BuildRequires: libjpeg-devel BuildRequires: libltdl-devel >= 1.4 BuildRequires: libpng-devel >= 1.0.8 %{?with_intl:BuildRequires: libstdc++-devel} -%{?with_webp:BuildRequires: libwebp-devel} BuildRequires: libtool >= 2:2.4.6 +%{?with_webp:BuildRequires: libwebp-devel} BuildRequires: libxml2-devel >= 1:2.7.6-4 %{?with_xsl:BuildRequires: libxslt-devel >= 1.1.0} %{?with_zip:BuildRequires: libzip-devel >= 1.3.1} @@ -230,17 +228,16 @@ BuildRequires: openssl-devel >= 1.0.1 %endif %{?with_oci:%{?with_instantclient:BuildRequires: oracle-instantclient-devel}} BuildRequires: pam-devel -%{?with_pcre:BuildRequires: pcre2-8-devel >= 10.30} +BuildRequires: pcre2-8-devel >= 10.30 BuildRequires: pkgconfig %{?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 BuildRequires: sed >= 4.0 %if %{with sqlite3} || %{with pdo_sqlite} -BuildRequires: sqlite3-devel >= 3.3.9 +BuildRequires: sqlite3-devel >= 3.7.4 %endif %{?with_systemtap:BuildRequires: systemtap-sdt-devel} BuildRequires: tar >= 1:1.22 @@ -263,9 +260,9 @@ BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) %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 20180731 -%define zend_module_api 20180731 -%define zend_extension_api 320180731 +%define php_api_version 20190902 +%define zend_module_api 20190902 +%define zend_extension_api 320190902 %define php_pdo_api_version 20170320 # Extension versions @@ -274,11 +271,11 @@ BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) %define fileinfover %{version} %define hashver %{version} %define intlver %{version} -%define jsonver 1.7.0 +%define jsonver %{version} %define pharver %{version} %define sqlite3ver %{version} -%define zipver 1.15.4 -%define phpdbgver 0.5.0 +%define zipver 1.15.5 +%define phpdbgver %{version} %define sodiumver %{version} %define _zend_zts %{!?with_zts:0}%{?with_zts:1} @@ -347,20 +344,33 @@ PHP - це мова написання скриптів, що вбудовуют використання PHP - заміна для CGI скриптів. %package -n apache-mod_%{name} -Summary: PHP DSO module for Apache 2.x -Summary(pl.UTF-8): Moduł DSO (Dynamic Shared Object) PHP dla Apache 2.x +Summary: PHP support for Apache 2.x +Summary(pl.UTF-8): Wsparcie 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 +Requires: apache-mod_%{name}-core = %{epoch}:%{version}-%{release} Provides: webserver(php) = %{version} Obsoletes: apache-mod_php < 4:5.3.28-7 Obsoletes: phpfi %description -n apache-mod_%{name} -PHP as DSO module for Apache 2.x. +PHP support for Apache 2.x. %description -n apache-mod_%{name} -l pl.UTF-8 +Wsparcie PHP dla Apache 2.x. + +%package -n apache-mod_%{name}-core +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 + +%description -n apache-mod_%{name}-core +PHP as DSO module for Apache 2.x. + +%description -n apache-mod_%{name}-core -l pl.UTF-8 PHP jako moduł DSO (Dynamic Shared Object) dla Apache 2.x. %package litespeed @@ -497,28 +507,42 @@ Provides: %{name}(zend_extension_api) = %{zend_extension_api} Provides: %{name}(zend_module_api) = %{zend_module_api} Provides: %{name}-core Provides: %{name}-date +Provides: %{name}-hash = %{epoch}:%{version}-%{release} +Provides: %{name}-pcre = %{epoch}:%{version}-%{release} Provides: %{name}-reflection +Provides: %{name}-spl = %{epoch}:%{version}-%{release} Provides: %{name}-standard Provides: php(core) = %{version} Provides: php(date) +Provides: php(hash) = %{hashver} Provides: php(libxml) +Provides: php(pcre) Provides: php(reflection) +Provides: php(spl) Provides: php(standard) %{!?with_mysqlnd:Obsoletes: %{name}-mysqlnd} -%{?with_pcre:%requires_ge_to pcre2-8 pcre2-8-devel} +%requires_ge_to pcre2-8 pcre2-8-devel Suggests: browscap Obsoletes: php-common < 4:5.3.28-7 -# withdrawn modules Obsoletes: php-filepro < 4:5.2.0 +Obsoletes: php-hash < 4:5.3.28-7 Obsoletes: php-hwapi < 4:5.2.0 Obsoletes: php-hyperwave < 3:5.0.0 Obsoletes: php-java < 3:5.0.0 Obsoletes: php-mcal < 3:5.0.0 +Obsoletes: php-pcre < 4:5.3.28-7 Obsoletes: php-pecl-domxml +Obsoletes: php-pecl-hash < %{hashver} Obsoletes: php-qtdom < 3:5.0.0 +Obsoletes: php-spl < 4:5.3.28-7 Conflicts: php4-common < 3:4.4.4-8 Conflicts: php55-common < 4:5.5.10-4 Conflicts: rpm < 4.4.2-0.2 +%if %{with mhash} +Provides: php(mhash) +Provides: php-mhash = %{epoch}:%{version}-%{release} +Obsoletes: php-mhash < 4:5.3.0 +%endif %description common Common files needed by both Apache modules and CGI/CLI SAPIs. @@ -542,10 +566,10 @@ Summary(ru.UTF-8): Пакет разработки для построения Summary(uk.UTF-8): Пакет розробки для побудови розширень PHP Group: Development/Languages/PHP Requires: %{name}-common = %{epoch}:%{version}-%{release} -Requires: autoconf >= 2.13 -Requires: automake +Requires: autoconf >= 2.59 +Requires: automake >= 1.4d Requires: libtool >= 2:2.4.6 -%{?with_pcre:Requires: pcre2-8-devel >= 10.30} +Requires: pcre2-8-devel >= 10.30 Requires: shtool Provides: php-devel = %{epoch}:%{version}-%{release} Obsoletes: php-devel @@ -762,6 +786,17 @@ support in image files. %description exif -l pl.UTF-8 Moduł PHP dodający obsługę znaczników EXIF w plikach obrazków. +%package ffi +Summary: %{modname} - Foreign Function Interface +Group: Libraries +URL: https://www.php.net/manual/en/book.ffi.php +Requires: %{name}-common = %{epoch}:%{version}-%{release} +Provides: php(ffi) = %{version} + +%description ffi +FFI is a multi-platform extension for PHP that allows you to bind to +functions from arbitrary shared libraries and call them. + %package fileinfo Summary: libmagic bindings Summary(pl.UTF-8): Wiązania do libmagic @@ -885,29 +920,6 @@ length number support with GNU MP library. 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://php.net/manual/en/book.gmp.php -Requires: %{name}-common = %{epoch}:%{version}-%{release} -Provides: php(hash) = %{hashver} -%if %{with mhash} -Provides: php(mhash) -Provides: php-mhash = %{epoch}:%{version}-%{release} -Obsoletes: php-mhash < 4:5.3.0 -%endif -Obsoletes: php-hash < 4:5.3.28-7 -Obsoletes: php-pecl-hash < %{hashver} - -%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 @@ -948,26 +960,6 @@ 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://php.net/manual/en/book.ibase.php -%if %{with interbase_inst} -%{?requires_php_extension} -%else -Requires: %{name}-common = %{epoch}:%{version}-%{release} -%endif -Provides: php(interbase) -Obsoletes: php-interbase < 4:5.3.28-7 - -%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) @@ -1203,22 +1195,6 @@ waitpid(), signal() etc. 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) -Obsoletes: php-pcre < 4:5.3.28-7 - -%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) @@ -1470,24 +1446,6 @@ 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://php.net/manual/en/book.recode.php -Requires: %{name}-common = %{epoch}:%{version}-%{release} -Requires: recode >= 3.5d-3 -Provides: php(recode) -Obsoletes: php-recode < 4:5.3.28-7 - -%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 @@ -1599,24 +1557,6 @@ Provides: php(sodium) = %{sodiumver} %description sodium A simple, low-level PHP extension for libsodium. -%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) -Obsoletes: php-spl < 4:5.3.28-7 - -%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 sqlite3 Summary: SQLite3 extension module for PHP Summary(pl.UTF-8): Moduł SQLite3 dla PHP @@ -1740,27 +1680,6 @@ 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://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) -Obsoletes: php-wddx < 4:5.3.28-7 - -%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 @@ -1864,7 +1783,7 @@ Summary(pl.UTF-8): Zarządzanie archiwami zip Group: Libraries URL: http://php.net/manual/en/book.zip.php Requires: %{name}-common = %{epoch}:%{version}-%{release} -%{?with_zip:Requires: libzip >= 1.3.1} +Requires: libzip >= 1.3.1 Provides: php(zip) = %{zipver} Obsoletes: php-pecl-zip < %{zipver} Obsoletes: php-zip < 4:5.3.28-7 @@ -1898,9 +1817,7 @@ cp -p php.ini-production php.ini %patch0 -p1 %patch1 -p1 %patch3 -p1 -%patch5 -p1 %patch7 -p1 -%{?with_milter:%patch8 -p1} %patch9 -p1 %patch10 -p1 %patch14 -p1 @@ -1911,32 +1828,25 @@ cp -p php.ini-production php.ini %patch23 -p1 %patch24 -p1 %patch25 -p1 -%patch26 -p1 %patch27 -p1 %patch29 -p1 %patch31 -p1 -%patch34 -p1 %patch37 -p1 %patch38 -p1 %patch39 -p1 %if %{with fpm} %patch41 -p1 -%patch42 -p1 %endif %patch43 -p1 %patch44 -p1 %patch50 -p1 -%patch51 -p1 -b .spl-shared -%patch52 -p1 -b .pcre-shared %patch53 -p1 %undos ext/spl/tests/SplFileInfo_getInode_basic.phpt %patch55 -p1 %patch59 -p1 -b .systzdata %patch66 -p1 %patch67 -p1 -%patch70 -p1 %patch71 -p1 -%patch72 -p1 -b .phar-shared %{__sed} -i -e '/PHP_ADD_LIBRARY_WITH_PATH/s#xmlrpc,#xmlrpc-epi,#' ext/xmlrpc/config.m4 @@ -1946,24 +1856,8 @@ find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f # com_dotnet is Win32-only %{__rm} -r ext/com_dotnet -# 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/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/pcre2lib -#%{__rm} -r ext/soap/interop %{__rm} -r ext/xmlrpc/libxmlrpc -#%{__rm} -r ext/zip/lib %{__rm} ext/date/lib/timezonedb.h cp -pf Zend/LICENSE{,.Zend} @@ -2093,14 +1987,14 @@ if test "$ver" != "%{zipver}"; then : Update the zipver macro and rebuild. exit 1 fi -ver=$(sed -n '/#define PHP_JSON_VERSION /{s/.* "//;s/".*$//;p}' ext/json/php_json.h) -if test "$ver" != "%{jsonver}"; then +ver=$(awk '/#define PHP_JSON_VERSION/ {print $3}' ext/json/php_json.h | xargs) +if test "$ver" != "PHP_VERSION"; then : Error: Upstream JSON version is now ${ver}, expecting %{jsonver}. : Update the jsonver macro and rebuild. exit 1 fi -ver=$(sed -n '/#define PHPDBG_VERSION /{s/.* "//;s/".*$//;p}' sapi/phpdbg/phpdbg.h) -if test "$ver" != "%{phpdbgver}"; then +ver=$(awk '/#define PHPDBG_VERSION/ {print $3}' sapi/phpdbg/phpdbg.h | xargs) +if test "$ver" != "PHP_VERSION"; then : Error: Upstream phpdbg version is now ${ver}, expecting %{phpdbgver}. : Update the phpdbgver macro and rebuild. exit 1 @@ -2129,12 +2023,22 @@ if test "$ver" != "PHP_VERSION"; then fi export EXTENSION_DIR="%{php_extensiondir}" + +# Set PEAR_INSTALLDIR to ensure that the hard-coded include_path +# includes the PEAR directory even though pear is packaged separately. +export PEAR_INSTALLDIR=%{php_pear_dir} + # 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,phpdbg,milter} + rm -f Makefile.{cgi-fcgi,fpm,cli,apxs2,litespeed,phpdbg} + + # Force use of system libtool: + mv build/libtool.m4 build/libtool.m4.saved + cat %{_aclocaldir}/{libtool,ltoptions,ltsugar,ltversion,lt~obsolete}.m4 > build/libtool.m4 %{__libtoolize} %{__aclocal} + cp -f /usr/share/automake/config.* . ./buildconf --force touch _built-conf @@ -2173,9 +2077,6 @@ apxs2 %if %{with phpdbg} phpdbg %endif -%if %{with milter} -milter -%endif " for sapi in $sapis; do : SAPI $sapi @@ -2201,14 +2102,11 @@ for sapi in $sapis; do sapi_args="--disable-cli --disable-cgi --with-apxs2=%{apxs2} --with-apache-version=$ver" ;; litespeed) - sapi_args='--disable-cli --disable-cgi --with-litespeed' + sapi_args='--disable-cli --disable-cgi --enable-litespeed' ;; phpdbg) sapi_args='--disable-cli --disable-cgi --enable-phpdbg %{?debug:--enable-phpdbg-debug}' ;; - milter) - sapi_args='--disable-cli --disable-cgi --with-milter' - ;; esac %configure \ @@ -2237,14 +2135,12 @@ for sapi in $sapis; do %{__enable_disable fileinfo fileinfo shared} \ %{__enable_disable ftp ftp shared} \ %{?with_intl:--enable-intl=shared} \ - --enable-libxml \ + --with-libxml \ %{__enable_disable mbstring mbstring shared,all} \ - --with-onig=/usr \ --enable-mbregex \ %{__enable_disable pcntl pcntl shared} \ %{__enable_disable pdo pdo shared} \ %{__enable_disable json json shared} \ - %{__enable_disable hash hash shared} \ --enable-xmlwriter=shared \ %if %{with fpm} --with-fpm-user=http \ @@ -2253,18 +2149,17 @@ for sapi in $sapis; do %if %{with pdo_dblib} --with-pdo-dblib=shared \ %endif -%if %{with interbase} && %{without interbase_inst} - --with-pdo-firebird=shared,/usr \ +%if %{with pdo_firebird} + --with-pdo-firebird=shared \ %endif %{?with_mhash:--with-mhash=yes} \ --with-mysql-sock=/var/lib/mysql/mysql.sock \ %{__with_without pdo_mysql pdo-mysql shared,%{!?with_mysqlnd:/usr}%{?with_mysqlnd:mysqlnd}} \ - %{?with_oci:--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} \ - %{?with_webp:--with-webp-dir=/usr} \ - --without-libexpat-dir \ + %{?with_pdo_oci:--with-pdo-oci=shared%{?with_instantclient:,instantclient,%{_libdir}}} \ + %{?with_pdo_odbc:--with-pdo-odbc=shared,unixODBC,/usr} \ + %{?with_pdo_pgsql:--with-pdo-pgsql=shared} \ + %{?with_pdo_sqlite:--with-pdo-sqlite=shared} \ + %{?with_webp:--with-webp} \ %{__enable_disable posix posix shared} \ --enable-shared \ %{__enable_disable session session shared} \ @@ -2277,22 +2172,22 @@ for sapi in $sapis; do --enable-sockets=shared \ %{__with_without sodium sodium shared} \ --enable-tokenizer=shared \ - %{?with_wddx:--enable-wddx=shared} \ --enable-xml=shared \ --enable-xmlreader=shared \ %{__with_without bz2 bz2 shared} \ %{__with_without curl curl shared} \ --with-db4 \ %{__with_without iconv iconv shared} \ - %{?with_enchant:--with-enchant=shared,/usr} \ - --with-freetype-dir=shared \ + %{?with_enchant:--with-enchant=shared} \ + --with-freetype \ %{__with_without gettext gettext shared} \ - %{__with_without gd gd shared%{?with_system_gd:,/usr}} \ + %{__enable_disable gd gd shared} \ + %{?with_system_gd:--with-external-gd} \ --with-gdbm \ %{__with_without gmp gmp shared} \ + %{__with_without ffi ffi shared} \ %{?with_imap:--with-imap=shared --with-imap-ssl} \ - %{?with_interbase:--with-interbase=shared%{!?with_interbase_inst:,/usr}} \ - --with-jpeg-dir=/usr \ + --with-jpeg \ %{?with_ldap:--with-ldap=shared --with-ldap-sasl} \ %{?with_mm:--with-mm} \ %{?with_mysqlnd:--enable-mysqlnd=shared} \ @@ -2302,25 +2197,22 @@ for sapi in $sapis; do %{?with_openssl:--with-openssl=shared} \ %{?with_kerberos5:--with-kerberos} \ --with-tcadb=/usr \ - %{__with_without pcre pcre-regex /usr} \ + --with-external-pcre \ + %{__with_without pcre_jit pcre-jit} \ %{__enable_disable filter filter shared} \ - --with-pear=%{php_pear_dir} \ - %{__with_without pgsql pgsql shared,/usr} \ + %{__with_without pgsql pgsql shared} \ %{__enable_disable phar phar shared} \ - --with-png-dir=/usr \ %{?with_pspell:--with-pspell=shared} \ %{__with_without readline readline shared} \ - %{?with_recode:--with-recode=shared} \ %{?with_snmp:--with-snmp=shared} \ %{!?with_pdo_sqlite:--without-pdo-sqlite} \ - %{__with_without sqlite3 sqlite3 shared,/usr} \ + %{__with_without sqlite3 sqlite3 shared} \ %{?with_tidy:--with-tidy=shared} \ - %{?with_odbc:--with-unixODBC=shared,/usr} \ + %{?with_odbc:--with-unixODBC=shared} \ %{__with_without xmlrpc xmlrpc shared,/usr} \ %{?with_xsl:--with-xsl=shared} \ --with-zlib=shared \ - --with-zlib-dir=shared,/usr \ - %{?with_zip:--enable-zip=shared,/usr --with-libzip} \ + %{?with_zip:--with-zip=shared} \ # save for debug cp -f Makefile Makefile.$sapi @@ -2358,10 +2250,6 @@ cp -af Makefile.cli Makefile PHPDBG_EXTRA_LIBS=-lreadline %endif -%if %{with milter} -%{__make} -f Makefile.milter milter -%endif - # CGI/FCGI %if %{with cgi} cp -pf php_config.h.cgi-fcgi main/php_config.h @@ -2385,36 +2273,7 @@ cp -pf php_config.h.cli main/php_config.h ./sapi/cli/php -n -dextension_dir=modules -dextension=xml.so -r '$p = xml_parser_create(); xml_parse_into_struct($p, "<", $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) - ext=extension - # opcache.so is zend extension - nm $so | grep -q zend_extension_entry && ext=zend_extension - 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" - # hash needs to be loaded before mysqlnd - [ "$mod" = "hash" ] && conf="hash.ini" - # mysqlnd needs to be loaded before mysqli,pdo_mysqli - [ "$mod" = "mysqlnd" ] && conf="MySQLND.ini" - echo "+ $conf" - cat > conf.d/$conf <<-EOF - ; Enable $mod $ext module - $ext=$mod.so - EOF - done -} -generate_inifiles -cp -p %{_sourcedir}/opcache.ini conf.d +GENERATE_INI=1 PHP=./sapi/cli/php EXTENSION_DIR=modules CONFIG_DIR=conf.d ./dep-tests.sh # 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 @@ -2467,9 +2326,11 @@ exit $rc %install rm -rf $RPM_BUILD_ROOT -install -d $RPM_BUILD_ROOT{%{_libdir}/{php,apache{,1}},%{_sysconfdir}/{apache,cgi}} \ +install -d \ + $RPM_BUILD_ROOT%{_libdir}/{php,apache} \ + $RPM_BUILD_ROOT%{_sysconfdir}/{conf,cgi-fcgi,cli,apache2handler}.d \ $RPM_BUILD_ROOT{%{_sbindir},%{_bindir}} \ - $RPM_BUILD_ROOT/etc/{apache/conf.d,httpd/conf.d} \ + $RPM_BUILD_ROOT/etc/httpd/conf.d \ $RPM_BUILD_ROOT%{_mandir}/man{1,8} \ cp -pf php_config.h.cli main/php_config.h @@ -2516,11 +2377,6 @@ touch $RPM_BUILD_ROOT%{_mandir}/man1/phpize.1 touch $RPM_BUILD_ROOT%{_bindir}/php-config touch $RPM_BUILD_ROOT%{_mandir}/man1/php-config.1 -%if %{with milter} -%{__make} -f Makefile.milter install-milter \ - INSTALL_ROOT=$RPM_BUILD_ROOT -%endif - # versioned libphp_common libtool --mode=install install -p libphp_common.la $RPM_BUILD_ROOT%{_libdir} %{__mv} $RPM_BUILD_ROOT%{_libdir}/libphp_common.la $RPM_BUILD_ROOT%{_libdir}/libphp_common%{php_suffix}.la @@ -2534,7 +2390,7 @@ sed -i -e "s|libphp_common|libphp_common%{php_suffix}|g" $RPM_BUILD_ROOT%{_libdi # install-cgi libtool --mode=install install -p sapi/cgi/php-cgi $RPM_BUILD_ROOT%{_bindir}/%{name}.cgi ln -sf %{name}.cgi $RPM_BUILD_ROOT%{_bindir}/%{name}.fcgi -cp -p %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/php-cgi-fcgi.ini +cp -p %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/cgi-fcgi.d/php.ini %endif # install FCGI PM @@ -2575,11 +2431,11 @@ touch $RPM_BUILD_ROOT%{_bindir}/php touch $RPM_BUILD_ROOT%{_mandir}/man1/php.1 cp -p php.ini $RPM_BUILD_ROOT%{_sysconfdir}/php.ini -cp -p %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/php-cli.ini +cp -p %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/cli.d/php.ini %if %{with apache2} cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/httpd/conf.d/70_mod_php.conf -cp -p %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/php-apache2handler.ini +cp -p %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/apache2handler.d/php.ini %{__rm} -f $RPM_BUILD_ROOT%{_libdir}/apache/libphp%{php_suffix}.la %endif @@ -2593,26 +2449,11 @@ grep -El '/etc/php/|/usr/lib/php/' $RPM_BUILD_ROOT%{_sysconfdir}/*.ini | xargs - install -d $RPM_BUILD_ROOT%{_sysconfdir}/conf.d cp -p 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 +cp -p %{_sourcedir}/opcache.ini $RPM_BUILD_ROOT%{_sysconfdir}/conf.d # for CLI SAPI only -%{__mv} $RPM_BUILD_ROOT%{_sysconfdir}/{conf.d/readline.ini,cli.d} - -# use system automake and {lib,sh}tool -ln -snf /usr/share/automake/config.{guess,sub} $RPM_BUILD_ROOT%{_libdir}/%{name}/build -ln -snf %{_bindir}/shtool $RPM_BUILD_ROOT%{_libdir}/%{name}/build -for fn in libtool.m4 lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4; do - f=%{_aclocaldir}/$fn - test -f $f || continue - ln -snf $f $RPM_BUILD_ROOT%{_libdir}/%{name}/build -done -for fn in ltmain.sh config/ltmain.sh build-aux/ltmain.sh; do - f=/usr/share/libtool/$fn - test -f $f || continue - ln -snf $f $RPM_BUILD_ROOT%{_libdir}/%{name}/build - break -done +%{__mv} $RPM_BUILD_ROOT%{_sysconfdir}/{conf.d/??_readline.ini,cli.d} + sed -i -e '/^phpdir/ s,/php/build,/%{name}/build,' $RPM_BUILD_ROOT%{_bindir}/phpize%{php_suffix} # for php-pecl-mailparse @@ -2626,8 +2467,8 @@ cp -a tests/* $RPM_BUILD_ROOT%{php_datadir}/tests/php # fix install paths, avoid evil rpaths sed -i -e "s|^libdir=.*|libdir='%{_libdir}'|" $RPM_BUILD_ROOT%{_libdir}/libphp_common%{php_suffix}.la -# better solution? -sed -i -e 's|libphp_common.la|$(libdir)/libphp_common%{php_suffix}.la|' $RPM_BUILD_ROOT%{_libdir}/%{name}/build/acinclude.m4 + +install -p ext/ext_skel.php $RPM_BUILD_ROOT%{_bindir} %clean rm -rf $RPM_BUILD_ROOT @@ -2712,7 +2553,6 @@ fi # 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 %triggerpostun common -- php-common < 4:5.3.28-7 @@ -2778,16 +2618,15 @@ fi \ %extension_scripts dom %extension_scripts enchant %extension_scripts exif +%extension_scripts ffi %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 @@ -2798,20 +2637,18 @@ fi \ %extension_scripts odbc %extension_scripts opcache %extension_scripts openssl -%extension_scripts pcre +%extension_scripts pcntl %extension_scripts pdo %extension_scripts pdo-dblib %extension_scripts pdo-firebird -%extension_scripts pdo-oci %extension_scripts pdo-mysql +%extension_scripts pdo-oci %extension_scripts pdo-odbc %extension_scripts pdo-pgsql %extension_scripts pdo-sqlite %extension_scripts pgsql -%extension_scripts pcntl %extension_scripts posix %extension_scripts pspell -%extension_scripts recode %extension_scripts session %extension_scripts shmop %extension_scripts simplexml @@ -2819,14 +2656,12 @@ fi \ %extension_scripts soap %extension_scripts sockets %extension_scripts sodium -%extension_scripts spl %extension_scripts sqlite3 %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 @@ -2851,9 +2686,12 @@ fi %files -n apache-mod_%{name} %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/mod_php.so + +%files -n apache-mod_%{name}-core +%defattr(644,root,root,755) +%dir %{_sysconfdir}/apache2handler.d +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/apache2handler.d/php.ini %attr(755,root,root) %{_libdir}/apache/libphp%{php_suffix}.so %endif @@ -2867,7 +2705,7 @@ fi %files cgi %defattr(644,root,root,755) %dir %{_sysconfdir}/cgi-fcgi.d -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php-cgi-fcgi.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/cgi-fcgi.d/php.ini %attr(755,root,root) %{_bindir}/%{name}.cgi %attr(755,root,root) %{_bindir}/%{name}.fcgi %endif @@ -2881,7 +2719,7 @@ fi %files cli %defattr(644,root,root,755) %dir %{_sysconfdir}/cli.d -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php-cli.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/cli.d/php.ini %attr(755,root,root) %{_bindir}/php%{php_suffix} %{_mandir}/man1/php%{php_suffix}.1* %ghost %{_bindir}/php @@ -2908,15 +2746,9 @@ fi %{_mandir}/man1/phpdbg%{php_suffix}.1* %endif -%if %{with milter} -%files milter -%defattr(644,root,root,755) -%attr(755,root,root) %{_bindir}/php-milter -%endif - %files common %defattr(644,root,root,755) -%doc CREDITS EXTENSIONS LICENSE NEWS UPGRADING* Zend/{LICENSE.Zend,README*} php.ini-* +%doc EXTENSIONS LICENSE NEWS UPGRADING* Zend/{LICENSE.Zend,README*} php.ini-* .gdbinit %dir %{_sysconfdir} %dir %{_sysconfdir}/conf.d %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/php.ini @@ -2928,7 +2760,8 @@ fi %files devel %defattr(644,root,root,755) -%doc CODING_STANDARDS README.{EXT_SKEL,PARAMETER_PARSING_API,SELF-CONTAINED-EXTENSIONS,STREAMS,SUBMITTING_PATCH,TESTING,UNIX-BUILD-SYSTEM,input_filter} +%doc CODING_STANDARDS.md docs/*.md +%attr(755,root,root) %{_bindir}/ext_skel.php %attr(755,root,root) %{_bindir}/phpize%{php_suffix} %attr(755,root,root) %{_bindir}/php-config%{php_suffix} %ghost %{_bindir}/phpize @@ -2945,7 +2778,7 @@ fi %if %{with bcmath} %files bcmath %defattr(644,root,root,755) -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/bcmath.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_bcmath.ini %attr(755,root,root) %{php_extensiondir}/bcmath.so %endif @@ -2953,7 +2786,7 @@ fi %files bz2 %defattr(644,root,root,755) %doc ext/bz2/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/bz2.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_bz2.ini %attr(755,root,root) %{php_extensiondir}/bz2.so %endif @@ -2961,7 +2794,7 @@ fi %files calendar %defattr(644,root,root,755) %doc ext/calendar/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/calendar.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_calendar.ini %attr(755,root,root) %{php_extensiondir}/calendar.so %endif @@ -2969,7 +2802,7 @@ fi %files ctype %defattr(644,root,root,755) %doc ext/calendar/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/ctype.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_ctype.ini %attr(755,root,root) %{php_extensiondir}/ctype.so %endif @@ -2977,15 +2810,15 @@ fi %files curl %defattr(644,root,root,755) %doc ext/curl/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/curl.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_curl.ini %attr(755,root,root) %{php_extensiondir}/curl.so %endif %if %{with dba} %files dba %defattr(644,root,root,755) -%doc ext/dba/{CREDITS,README} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/dba.ini +%doc ext/dba/CREDITS +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_dba.ini %attr(755,root,root) %{php_extensiondir}/dba.so %endif @@ -2993,7 +2826,7 @@ fi %files dom %defattr(644,root,root,755) %doc ext/dom/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/dom.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_dom.ini %attr(755,root,root) %{php_extensiondir}/dom.so %endif @@ -3001,7 +2834,7 @@ fi %files enchant %defattr(644,root,root,755) %doc ext/enchant/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/enchant.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_enchant.ini %attr(755,root,root) %{php_extensiondir}/enchant.so %endif @@ -3009,15 +2842,23 @@ fi %files exif %defattr(644,root,root,755) %doc ext/exif/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/exif.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_exif.ini %attr(755,root,root) %{php_extensiondir}/exif.so %endif +%if %{with ffi} +%files ffi +%defattr(644,root,root,755) +%doc ext/ffi/CREDITS +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_ffi.ini +%attr(755,root,root) %{php_extensiondir}/ffi.so +%endif + %if %{with fileinfo} %files fileinfo %defattr(644,root,root,755) %doc ext/fileinfo/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/fileinfo.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_fileinfo.ini %attr(755,root,root) %{php_extensiondir}/fileinfo.so %endif @@ -3025,7 +2866,7 @@ fi %files filter %defattr(644,root,root,755) %doc ext/filter/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/filter.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_filter.ini %attr(755,root,root) %{php_extensiondir}/filter.so %endif @@ -3033,7 +2874,7 @@ fi %files ftp %defattr(644,root,root,755) %doc ext/ftp/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/ftp.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_ftp.ini %attr(755,root,root) %{php_extensiondir}/ftp.so %endif @@ -3041,7 +2882,7 @@ fi %files gd %defattr(644,root,root,755) %doc ext/gd/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/gd.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_gd.ini %attr(755,root,root) %{php_extensiondir}/gd.so %endif @@ -3049,7 +2890,7 @@ fi %files gettext %defattr(644,root,root,755) %doc ext/gettext/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/gettext.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_gettext.ini %attr(755,root,root) %{php_extensiondir}/gettext.so %endif @@ -3057,23 +2898,15 @@ fi %files gmp %defattr(644,root,root,755) %doc ext/gmp/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/gmp.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_gmp.ini %attr(755,root,root) %{php_extensiondir}/gmp.so %endif -%if %{with hash} -%files hash -%defattr(644,root,root,755) -%doc ext/hash/{CREDITS,README} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/hash.ini -%attr(755,root,root) %{php_extensiondir}/hash.so -%endif - %if %{with iconv} %files iconv %defattr(644,root,root,755) %doc ext/iconv/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/iconv.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_iconv.ini %attr(755,root,root) %{php_extensiondir}/iconv.so %endif @@ -3081,23 +2914,15 @@ fi %files imap %defattr(644,root,root,755) %doc ext/imap/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/imap.ini +%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) -%doc ext/interbase/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/interbase.ini -%attr(755,root,root) %{php_extensiondir}/interbase.so -%endif - %if %{with intl} %files intl %defattr(644,root,root,755) %doc ext/intl/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/intl.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_intl.ini %attr(755,root,root) %{php_extensiondir}/intl.so %endif @@ -3105,7 +2930,7 @@ fi %files json %defattr(644,root,root,755) %doc ext/json/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/json.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_json.ini %attr(755,root,root) %{php_extensiondir}/json.so %endif @@ -3113,7 +2938,7 @@ fi %files ldap %defattr(644,root,root,755) %doc ext/ldap/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/ldap.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_ldap.ini %attr(755,root,root) %{php_extensiondir}/ldap.so %endif @@ -3121,7 +2946,7 @@ fi %files mbstring %defattr(644,root,root,755) %doc ext/mbstring/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/mbstring.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_mbstring.ini %attr(755,root,root) %{php_extensiondir}/mbstring.so %endif @@ -3129,7 +2954,7 @@ fi %files mysqli %defattr(644,root,root,755) %doc ext/mysqli/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/mysqli.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_mysqli.ini %attr(755,root,root) %{php_extensiondir}/mysqli.so %endif @@ -3137,7 +2962,7 @@ fi %files mysqlnd %defattr(644,root,root,755) %doc ext/mysqlnd/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/MySQLND.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_mysqlnd.ini %attr(755,root,root) %{php_extensiondir}/mysqlnd.so %endif @@ -3145,7 +2970,7 @@ fi %files oci8 %defattr(644,root,root,755) %doc ext/oci8/{CREDITS,README} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/oci8.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_oci8.ini %attr(755,root,root) %{php_extensiondir}/oci8.so %endif @@ -3153,14 +2978,14 @@ fi %files odbc %defattr(644,root,root,755) %doc ext/odbc/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/odbc.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_odbc.ini %attr(755,root,root) %{php_extensiondir}/odbc.so %endif %if %{with opcache} %files opcache %defattr(644,root,root,755) -%doc ext/opcache/README +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_opcache.ini %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/opcache.ini %attr(755,root,root) %{php_extensiondir}/opcache.so %endif @@ -3168,48 +2993,40 @@ fi %if %{with openssl} %files openssl %defattr(644,root,root,755) -%doc ext/openssl/{CREDITS,README} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/openssl.ini +%doc ext/openssl/CREDITS +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_openssl.ini %attr(755,root,root) %{php_extensiondir}/openssl.so %endif %if %{with pcntl} %files pcntl %defattr(644,root,root,755) -%doc ext/pcntl/{CREDITS,README} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pcntl.ini +%doc ext/pcntl/CREDITS +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_pcntl.ini %attr(755,root,root) %{php_extensiondir}/pcntl.so %endif -%if %{with pcre} -%files pcre -%defattr(644,root,root,755) -%doc ext/pcre/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/PCRE.ini -%attr(755,root,root) %{php_extensiondir}/pcre.so -%endif - %if %{with pdo} %files pdo %defattr(644,root,root,755) -%doc ext/pdo/{CREDITS,README} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo.ini +%doc ext/pdo/CREDITS +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_pdo.ini %attr(755,root,root) %{php_extensiondir}/pdo.so %endif %if %{with pdo_dblib} %files pdo-dblib %defattr(644,root,root,755) -%doc ext/pdo_dblib/{CREDITS,README} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_dblib.ini +%doc ext/pdo_dblib/CREDITS +%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} +%if %{with pdo_firebird} %files pdo-firebird %defattr(644,root,root,755) %doc ext/pdo_firebird/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_firebird.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_pdo_firebird.ini %attr(755,root,root) %{php_extensiondir}/pdo_firebird.so %endif @@ -3217,31 +3034,31 @@ fi %files pdo-mysql %defattr(644,root,root,755) %doc ext/pdo_mysql/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_mysql.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_pdo_mysql.ini %attr(755,root,root) %{php_extensiondir}/pdo_mysql.so %endif -%if %{with oci} +%if %{with pdo_oci} %files pdo-oci %defattr(644,root,root,755) %doc ext/pdo_oci/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_oci.ini +%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} +%if %{with pdo_odbc} %files pdo-odbc %defattr(644,root,root,755) %doc ext/pdo_odbc/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_odbc.ini +%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} +%if %{with pdo_pgsql} %files pdo-pgsql %defattr(644,root,root,755) %doc ext/pdo_pgsql/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_pgsql.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_pdo_pgsql.ini %attr(755,root,root) %{php_extensiondir}/pdo_pgsql.so %endif @@ -3249,15 +3066,15 @@ fi %files pdo-sqlite %defattr(644,root,root,755) %doc ext/pdo_sqlite/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pdo_sqlite.ini +%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) -%doc ext/pgsql/{CREDITS,README} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pgsql.ini +%doc ext/pgsql/CREDITS +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_pgsql.ini %attr(755,root,root) %{php_extensiondir}/pgsql.so %endif @@ -3265,7 +3082,7 @@ fi %files phar %defattr(644,root,root,755) %doc ext/phar/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/phar.ini +%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%{php_suffix}.phar %{_mandir}/man1/phar%{php_suffix}.1* @@ -3278,113 +3095,99 @@ fi %files posix %defattr(644,root,root,755) %doc ext/posix/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/posix.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_posix.ini %attr(755,root,root) %{php_extensiondir}/posix.so %endif %if %{with pspell} %files pspell %defattr(644,root,root,755) -%doc ext/pspell/{CREDITS,README} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/pspell.ini +%doc ext/pspell/CREDITS +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_pspell.ini %attr(755,root,root) %{php_extensiondir}/pspell.so %endif %if %{with readline} %files readline %defattr(644,root,root,755) -%doc ext/readline/{CREDITS,README*} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/cli.d/readline.ini +%doc ext/readline/CREDITS +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/cli.d/??_readline.ini %attr(755,root,root) %{php_extensiondir}/readline.so %endif -%if %{with recode} -%files recode -%defattr(644,root,root,755) -%doc ext/recode/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/recode.ini -%attr(755,root,root) %{php_extensiondir}/recode.so -%endif - %if %{with session} %files session %defattr(644,root,root,755) %doc ext/session/CREDITS %doc ext/session/mod_files.sh -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/Session.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_session.ini %attr(755,root,root) %{php_extensiondir}/session.so %endif %files shmop %defattr(644,root,root,755) -%doc ext/shmop/{CREDITS,README} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/shmop.ini +%doc ext/shmop/CREDITS +%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) -%doc ext/simplexml/{CREDITS,README} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/simplexml.ini +%doc ext/simplexml/CREDITS +%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) %doc ext/snmp/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/snmp.ini +%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) %doc ext/soap/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/soap.ini +%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) %doc ext/sockets/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/sockets.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_sockets.ini %attr(755,root,root) %{php_extensiondir}/sockets.so %if %{with sodium} %files sodium %defattr(644,root,root,755) %doc ext/sodium/{README.md,CREDITS} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/sodium.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_sodium.ini %attr(755,root,root) %{php_extensiondir}/sodium.so %endif -%files spl -%defattr(644,root,root,755) -%doc ext/spl/{CREDITS,README,examples} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/SPL.ini -%attr(755,root,root) %{php_extensiondir}/spl.so - %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 +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_sqlite3.ini %attr(755,root,root) %{php_extensiondir}/sqlite3.so %endif %files sysvmsg %defattr(644,root,root,755) %doc ext/sysvmsg/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/sysvmsg.ini +%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) %doc ext/sysvsem/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/sysvsem.ini +%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) %doc ext/sysvshm/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/sysvshm.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_sysvshm.ini %attr(755,root,root) %{php_extensiondir}/sysvshm.so %files tests @@ -3406,55 +3209,47 @@ fi %files tidy %defattr(644,root,root,755) %doc ext/tidy/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/tidy.ini +%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) %doc ext/tokenizer/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/tokenizer.ini +%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) -%doc ext/wddx/CREDITS -%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) %doc ext/xml/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/xml.ini +%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) -%doc ext/xmlreader/{CREDITS,README} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/xmlreader.ini +%doc ext/xmlreader/CREDITS +%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) %doc ext/xmlrpc/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/xmlrpc.ini +%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) %doc ext/xmlwriter/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/xmlwriter.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_xmlwriter.ini %attr(755,root,root) %{php_extensiondir}/xmlwriter.so %if %{with xsl} %files xsl %defattr(644,root,root,755) %doc ext/xsl/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/xsl.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_xsl.ini %attr(755,root,root) %{php_extensiondir}/xsl.so %endif @@ -3462,12 +3257,12 @@ fi %files zip %defattr(644,root,root,755) %doc ext/zip/{CREDITS,examples} -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/zip.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_zip.ini %attr(755,root,root) %{php_extensiondir}/zip.so %endif %files zlib %defattr(644,root,root,755) %doc ext/zlib/CREDITS -%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/zlib.ini +%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/??_zlib.ini %attr(755,root,root) %{php_extensiondir}/zlib.so diff --git a/skip-tests.sh b/skip-tests.sh index a090b7d..0180e32 100644 --- a/skip-tests.sh +++ b/skip-tests.sh @@ -83,10 +83,6 @@ mv ext/standard/tests/general_functions/proc_nice_basic.phpt{,.skip} mv ext/standard/tests/general_functions/proc_open02.phpt{,.skip} # Test setlocale() function : usage variations - Setting all available locales in the platform mv ext/standard/tests/strings/setlocale_variation2.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) diff --git a/spl-shared.patch b/spl-shared.patch deleted file mode 100644 index 9680530..0000000 --- a/spl-shared.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- php-7.0/ext/spl/config.m4~ 2015-05-21 17:57:06.000000000 +0300 -+++ php-7.0/ext/spl/config.m4 2015-05-23 11:25:19.609715006 +0300 -@@ -2,6 +2,6 @@ - dnl config.m4 for extension SPL - - 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,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) -+ 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,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) - 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-7.1.0alpha1/ext/pdo/pdo.c~ 2016-06-07 23:56:47.000000000 +0300 -+++ php-7.1.0alpha1/ext/pdo/pdo.c 2016-06-13 23:24:51.238259131 +0300 -@@ -117,7 +117,9 @@ - - /* {{{ pdo_functions[] */ - static const zend_module_dep pdo_deps[] = { -+#ifdef HAVE_SPL && !COMPILE_DL_SPL - ZEND_MOD_REQUIRED("spl") -+#endif - ZEND_MOD_END - }; - /* }}} */ ---- 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 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; \ diff --git a/suhosin.patch b/suhosin.patch deleted file mode 100644 index 378a4e4..0000000 --- a/suhosin.patch +++ /dev/null @@ -1,5685 +0,0 @@ -suhosin hardening patch - -this patch was downloaded from: - - http://download.suhosin.org/suhosin-patch-5.3.4-0.9.10.patch.gz - -the following modifications have been made: - - * removed changes to ./configure & ./main/php_config.h.in since those - files are autogenerated - * "quilt refresh" has been run to clean up the offsets, etc - * logo patch disabled (needs porting to DATA_URIs) - * expose php disabled (unref symbols) ---- php-5.5.0alpha1/Zend/Makefile.am~ 2012-11-13 22:00:16.000000000 +0200 -+++ php-5.5.0alpha1/Zend/Makefile.am 2012-11-17 13:37:04.263279745 +0200 -@@ -18,7 +18,7 @@ - zend_default_classes.c \ - zend_iterators.c zend_interfaces.c zend_exceptions.c \ - zend_strtod.c zend_closures.c zend_float.c zend_string.c zend_signal.c \ -- zend_generators.c -+ zend_generators.c zend_canary.c zend_alloc_canary.c - - libZend_la_LDFLAGS = - libZend_la_LIBADD = @ZEND_EXTRA_LIBS@ ---- a/Zend/Zend.dsp -+++ b/Zend/Zend.dsp -@@ -251,6 +251,14 @@ SOURCE=.\zend_strtod.c - # End Source File - # Begin Source File - -+SOURCE=.\zend_canary.c -+# End Source File -+# Begin Source File -+ -+SOURCE=.\zend_alloc_canary.c -+# End Source File -+# Begin Source File -+ - SOURCE=.\zend_ts_hash.c - # End Source File - # Begin Source File ---- a/Zend/ZendTS.dsp -+++ b/Zend/ZendTS.dsp -@@ -281,6 +281,14 @@ SOURCE=.\zend_strtod.c - # End Source File - # Begin Source File - -+SOURCE=.\zend_canary.c -+# End Source File -+# Begin Source File -+ -+SOURCE=.\zend_alloc_canary.c -+# End Source File -+# Begin Source File -+ - SOURCE=.\zend_ts_hash.c - # End Source File - # Begin Source File ---- a/Zend/zend.c -+++ b/Zend/zend.c -@@ -61,6 +61,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, const void *data TSRMLS_DC); -@@ -102,6 +106,74 @@ static ZEND_INI_MH(OnUpdateScriptEncodin - /* }}} */ - - -+#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) ---- a/Zend/zend.h -+++ b/Zend/zend.h -@@ -688,6 +688,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); - -@@ -849,6 +852,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 */ - - /* ---- a/Zend/zend_alloc.c -+++ b/Zend/zend_alloc.c -@@ -32,6 +32,10 @@ - # include - #endif - -+#if SUHOSIN_PATCH -+#include "suhosin_patch.h" -+#endif -+ - #ifdef ZEND_WIN32 - # include - # include -@@ -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*); -@@ -448,6 +471,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) \ -@@ -525,18 +551,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>>ZEND_MM_ALIGNMENT_LOG2)) - -@@ -598,6 +637,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 - -@@ -720,7 +797,7 @@ static inline unsigned int zend_mm_low_b - #endif - } - --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; -@@ -737,7 +814,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; -@@ -750,15 +827,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; - } -@@ -770,14 +847,14 @@ 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); - } - } - -@@ -791,6 +868,12 @@ static inline void zend_mm_remove_from_f - 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"); -@@ -829,14 +912,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)) { -@@ -854,7 +944,7 @@ subst_block: - } - } - --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; - -@@ -878,14 +968,14 @@ static inline void zend_mm_add_to_rest_l - - ZEND_MM_SET_MAGIC(mm_block, MEM_BLOCK_FREED); - -- 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_init(zend_mm_heap *heap) -+static void zend_mm_init(zend_mm_heap *heap) - { - zend_mm_free_block* p; - int i; -@@ -903,13 +993,21 @@ 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)); - heap->rest_count = 0; -+ -+#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) -@@ -930,12 +1028,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; -@@ -1031,14 +1130,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; -@@ -1072,6 +1177,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 */ -@@ -1119,12 +1230,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; - -@@ -1132,22 +1243,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)); - mm_heap->rest_count = 0; - - free(heap); -@@ -1156,7 +1267,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; -@@ -1226,6 +1341,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) - { -@@ -1594,7 +1730,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; -@@ -1611,7 +1751,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; -@@ -1730,12 +1870,23 @@ ZEND_API void zend_mm_shutdown(zend_mm_h - zend_mm_add_to_free_list(heap, b); - } - 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, -@@ -1746,7 +1897,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) { -@@ -1821,7 +1976,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); -@@ -1845,7 +2000,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); -@@ -1854,7 +2009,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) { -@@ -1870,9 +2025,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; -@@ -1902,9 +2060,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); - HANDLE_UNBLOCK_INTERRUPTIONS(); -@@ -1919,7 +2082,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 -@@ -1934,7 +2097,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)) { -@@ -1946,7 +2109,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); - } - } - -@@ -2042,13 +2205,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); - } - -@@ -2069,19 +2238,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 -@@ -2116,6 +2292,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); -@@ -2127,7 +2306,11 @@ static void *_zend_mm_realloc_int(zend_m - TSRMLS_FETCH(); - #endif - 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 - } - - HANDLE_BLOCK_INTERRUPTIONS(); -@@ -2135,6 +2318,9 @@ static void *_zend_mm_realloc_int(zend_m - 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)) { -@@ -2165,6 +2351,11 @@ static void *_zend_mm_realloc_int(zend_m - } - ZEND_MM_SET_DEBUG_INFO(mm_block, size, 0, 0); - 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; - } - -@@ -2180,17 +2371,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; -@@ -2199,7 +2395,7 @@ 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) { -@@ -2249,6 +2445,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)))) { -@@ -2349,39 +2550,75 @@ 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 -- _zend_mm_free_int(heap, p ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); - HANDLE_UNBLOCK_INTERRUPTIONS(); - 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; - } -@@ -2393,6 +2630,24 @@ ZEND_API size_t _zend_mm_block_size(zend - 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; -+ } -+ 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 -+} -+ -+#endif - - /**********************/ - /* Allocation Manager */ -@@ -2410,6 +2665,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; -@@ -2422,7 +2678,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) -@@ -2433,7 +2695,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) -@@ -2443,7 +2711,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) -@@ -2451,8 +2725,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) - -@@ -2523,7 +2804,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)); -@@ -2663,6 +2944,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) - { -@@ -2687,6 +2969,7 @@ static void alloc_globals_dtor(zend_allo - } - #endif - -+#ifndef SUHOSIN_MM_CLONE_FILE - ZEND_API void start_memory_manager(TSRMLS_D) - { - #ifdef ZTS -@@ -2751,6 +3034,7 @@ ZEND_API void _full_mem_check(int silent - zend_debug_alloc_output("------------------------------------------------\n"); - } - #endif -+#endif - - /* - * Local variables: ---- a/Zend/zend_alloc.h -+++ b/Zend/zend_alloc.h -@@ -189,6 +189,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); ---- /dev/null -+++ b/Zend/zend_alloc_canary.c -@@ -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 | -+ +----------------------------------------------------------------------+ -+ */ -+/* $Id: zend_alloc_canary.c, $ */ -+ -+#include "zend.h" -+#include "zend_alloc.h" -+#include "zend_globals.h" -+#include "zend_operators.h" -+ -+#ifdef HAVE_SIGNAL_H -+# include -+#endif -+#ifdef HAVE_UNISTD_H -+# include -+#endif -+ -+#if SUHOSIN_PATCH -+#include "suhosin_patch.h" -+#endif -+ -+#ifdef ZEND_WIN32 -+# include -+# include -+#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 -+#include -+#if HAVE_LIMITS_H -+#include -+#endif -+#include -+#include -+ -+#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 -+# 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>>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: -+ */ -+ ---- /dev/null -+++ b/Zend/zend_canary.c -@@ -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 | -+ +----------------------------------------------------------------------+ -+ */ -+/* $Id: zend_canary.c,v 1.1 2004/11/26 12:45:41 ionic Exp $ */ -+ -+#include "zend.h" -+ -+#include -+#include -+ -+ -+#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 -+ */ ---- a/Zend/zend_compile.c -+++ b/Zend/zend_compile.c -@@ -141,6 +141,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]; ---- a/Zend/zend_compile.h -+++ b/Zend/zend_compile.h -@@ -685,6 +685,11 @@ ZEND_API zend_bool zend_is_auto_global(c - ZEND_API zend_bool zend_is_auto_global_quick(const char *name, uint name_len, ulong hashval 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); - - int zend_add_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC); ---- a/Zend/zend_constants.c -+++ b/Zend/zend_constants.c -@@ -117,6 +117,76 @@ 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; ---- a/Zend/zend_errors.h -+++ b/Zend/zend_errors.h -@@ -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 | E_STRICT) - #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 */ - - /* ---- php-5.5.0/Zend/zend_hash.c~ 2013-06-20 23:57:44.000000000 +0300 -+++ php-5.5.0/Zend/zend_hash.c 2013-06-20 23:58:38.383348644 +0300 -@@ -21,6 +21,7 @@ - - #include "zend.h" - #include "zend_globals.h" -+#include "zend_compile.h" - - #define CONNECT_TO_BUCKET_DLLIST(element, list_head) \ - (element)->pNext = (list_head); \ -@@ -103,6 +104,199 @@ ZEND_API ulong zend_hash_func(const char - return zend_inline_hash_func(arKey, nKeyLength); - } - -+#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 - - #define UPDATE_DATA(ht, p, pData, nDataSize) \ - if (nDataSize == sizeof(void*)) { \ -@@ -163,6 +357,7 @@ ZEND_API int _zend_hash_init(HashTable * - - ht->nTableMask = 0; /* 0 means that ht->arBuckets is uninitialized */ - ht->pDestructor = pDestructor; -+ zend_hash_add_destructor(pDestructor); - ht->arBuckets = (Bucket**)&uninitialized_bucket; - ht->pListHead = NULL; - ht->pListTail = NULL; -@@ -230,6 +425,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); - } -@@ -307,6 +503,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); - } -@@ -394,6 +591,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); - } -@@ -726,6 +726,7 @@ - ht->pInternalPointer = p->pListNext; - } - ht->nNumOfElements--; -+ zend_hash_check_destructor(ht->pDestructor); - if (ht->pDestructor) { - ht->pDestructor(p->pData); - } -@@ -553,6 +752,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; -@@ -646,6 +846,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); - } -@@ -666,6 +867,7 @@ ZEND_API void zend_hash_graceful_destroy - IS_CONSISTENT(ht); - - p = ht->pListHead; -+ zend_hash_check_destructor(ht->pDestructor); - while (p != NULL) { - p = zend_hash_apply_deleter(ht, p); - } ---- a/Zend/zend_llist.c -+++ b/Zend/zend_llist.c -@@ -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; ---- a/Zend/zend_operators.c -+++ b/Zend/zend_operators.c -@@ -150,9 +150,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); -@@ -184,7 +189,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); \ - } \ -@@ -226,6 +232,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: \ -@@ -268,6 +275,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; \ -@@ -353,6 +361,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); - } -@@ -413,6 +424,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); - } -@@ -499,8 +513,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); -@@ -614,6 +634,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)); ---- a/Zend/zend_variables.c -+++ b/Zend/zend_variables.c -@@ -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); - str_free(zvalue->value.str.val); -+#if SUHOSIN_PATCH -+ zvalue->value.str.len = 0; -+#endif - break; - case IS_ARRAY: - case IS_CONSTANT_ARRAY: ---- php-5.5.0alpha1/configure.in~ 2012-11-17 13:36:25.000000000 +0200 -+++ php-5.5.0alpha1/configure.in 2012-11-17 13:37:55.705648875 +0200 -@@ -359,6 +359,7 @@ case $host_alias in - ;; - esac - -+sinclude(main/suhosin_patch.m4) - - dnl Include Zend and TSRM configurations. - dnl ------------------------------------------------------------------------- -@@ -1439,7 +1439,7 @@ - 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 \ -- 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 \ -@@ -1467,7 +1467,8 @@ - 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_string.c zend_signal.c zend_generators.c) -+ zend_closures.c zend_float.c zend_string.c zend_signal.c zend_generators.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) ---- a/ext/standard/dl.c -+++ b/ext/standard/dl.c -@@ -246,6 +246,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; - } - /* }}} */ -#--- a/ext/standard/info.c -#+++ b/ext/standard/info.c -#@@ -785,6 +785,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("\"Suhosin\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?"
":"\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 Hardened-PHP Project\n"); -#+ PUTS("Copyright (c) 2007-2009 SektionEins GmbH\n"); -#+ } -#+ php_info_print_box_end(); -#+ -# /* Zend Engine */ -# php_info_print_box_start(0); -# if (expose_php && !sapi_module.phpinfo_as_text) { ---- a/ext/standard/syslog.c -+++ b/ext/standard/syslog.c -@@ -40,6 +40,7 @@ - */ - 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 */ -@@ -95,6 +96,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; ---- a/main/fopen_wrappers.c -+++ b/main/fopen_wrappers.c -@@ -84,13 +84,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 */ ---- a/main/main.c -+++ b/main/main.c -@@ -92,6 +92,9 @@ - - #include "SAPI.h" - #include "rfc1867.h" -+#if SUHOSIN_PATCH -+#include "suhosin_globals.h" -+#endif - - #if HAVE_MMAP - # if HAVE_UNISTD_H -@@ -473,7 +476,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_BOOLEAN("file_uploads", "1", PHP_INI_SYSTEM, OnUpdateBool, file_uploads, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("upload_max_filesize", "2M", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateLong, upload_max_filesize, php_core_globals, core_globals) -@@ -1884,6 +1887,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) -@@ -1927,6 +1934,10 @@ int php_module_startup(sapi_module_struc - php_win32_init_rng_lock(); - #endif - -+#if SUHOSIN_PATCH -+ suhosin_startup(); -+#endif -+ - module_shutdown = 0; - module_startup = 1; - sapi_initialize_empty_request(TSRMLS_C); -@@ -2051,7 +2062,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); - ---- a/main/php.h -+++ b/main/php.h -@@ -453,6 +453,10 @@ END_EXTERN_C() - #endif - #endif /* !XtOffsetOf */ - -+#if SUHOSIN_PATCH -+#include "suhosin_patch.h" -+#endif -+ - #endif - - /* -#--- php-5.4.6/main/php_logos.c~ 2012-08-23 12:04:01.000000000 +0300 -#+++ php-5.4.6/main/php_logos.c 2012-08-23 12:04:39.401608052 +0300 -#@@ -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) -#@@ -64,6 +64,10 @@ -# 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; -# } -# ---- a/main/snprintf.c -+++ b/main/snprintf.c -@@ -782,6 +782,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) { -@@ -792,6 +796,7 @@ static int format_converter(register buf - if (adjust_precision && precision < s_len) { - s_len = precision; - } -+#endif - break; - case 'u': - switch(modifier) { -@@ -1093,7 +1098,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; - - /* ---- a/main/spprintf.c -+++ b/main/spprintf.c -@@ -390,6 +390,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) { -@@ -400,6 +404,7 @@ static void xbuf_format_converter(smart_ - if (adjust_precision && precision < s_len) { - s_len = precision; - } -+#endif - break; - case 'u': - switch(modifier) { -@@ -700,7 +705,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; - - /* ---- /dev/null -+++ b/main/suhosin_globals.h -@@ -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 | -+ +----------------------------------------------------------------------+ -+ */ -+ -+#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: -+ */ ---- /dev/null -+++ b/main/suhosin_logo.h -@@ -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" -+ ; ---- /dev/null -+++ b/main/suhosin_patch.c -@@ -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 | -+ +----------------------------------------------------------------------+ -+ */ -+/* $Id: suhosin_patch.c,v 1.2 2004/11/21 09:38:52 ionic Exp $ */ -+ -+#include "php.h" -+ -+#include -+#include -+#include -+ -+#if HAVE_UNISTD_H -+#include -+#endif -+#include "SAPI.h" -+#include "php_globals.h" -+ -+#if SUHOSIN_PATCH -+ -+#ifdef HAVE_SYS_SOCKET_H -+#include -+#endif -+ -+#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE) -+#undef AF_UNIX -+#endif -+ -+#if defined(AF_UNIX) -+#include -+#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 -+ */ ---- /dev/null -+++ b/main/suhosin_patch.h -@@ -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 | -+ +----------------------------------------------------------------------+ -+ */ -+ -+#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 -+#include -+#include -+ -+#if defined(DARWIN) -+#include -+#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: -+ */ ---- /dev/null -+++ b/main/suhosin_patch.m4 -@@ -0,0 +1,8 @@ -+dnl -+dnl $Id: suhosin_patch.m4,v 1.1 2004/11/14 13:24:24 ionic Exp $ -+dnl -+dnl This file contains Suhosin Patch for PHP specific autoconf functions. -+dnl -+ -+AC_DEFINE(SUHOSIN_PATCH, 1, [Suhosin Patch]) -+ ---- a/sapi/apache/mod_php5.c -+++ b/sapi/apache/mod_php5.c -@@ -965,7 +965,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 ---- a/sapi/apache2filter/sapi_apache2.c -+++ b/sapi/apache2filter/sapi_apache2.c -@@ -581,7 +581,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 - } - } - ---- a/sapi/apache2handler/sapi_apache2.c -+++ b/sapi/apache2handler/sapi_apache2.c -@@ -406,7 +406,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 - } - } - ---- a/sapi/apache_hooks/mod_php5.c -+++ b/sapi/apache_hooks/mod_php5.c -@@ -1251,7 +1251,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 ---- a/sapi/cgi/cgi_main.c -+++ b/sapi/cgi/cgi_main.c -@@ -2188,10 +2188,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-2014 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-2014 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-2014 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-2014 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-2014 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-2014 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); -+ #endif - #endif - php_request_shutdown((void *) 0); - fcgi_shutdown(); ---- a/sapi/cli/php_cli.c -+++ b/sapi/cli/php_cli.c -@@ -687,7 +687,11 @@ static int do_cli(int argc, char **argv - goto out; - - case 'v': /* show php version & quit */ -+#if SUHOSIN_PATCH -+ php_printf("PHP %s with Suhosin-Patch (%s) (built: %s %s) %s\nCopyright (c) 1997-2014 The PHP Group\n%s", -+#else - php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2014 The PHP Group\n%s", -+#endif - PHP_VERSION, cli_sapi_module.name, __DATE__, __TIME__, - #if ZEND_DEBUG && defined(HAVE_GCOV) - "(DEBUG GCOV)", ---- php-5.5.15/sapi/litespeed/lsapi_main.c 2014-08-21 11:45:02.000000000 +0300 -+++ php-5.5.15/sapi/litespeed/lsapi_main.c 2014-08-25 11:50:36.603155796 +0300 -@@ -734,11 +546,19 @@ - case 'v': - if (php_request_startup(TSRMLS_C) != FAILURE) { -+#if SUHOSIN_PATCH -+#if ZEND_DEBUG -+ php_printf("PHP %s with Suhosin-Patch (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2014 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); -+#else -+ php_printf("PHP %s with Suhosin-Patch (%s) (built: %s %s)\nCopyright (c) 1997-2014 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-2014 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-2014 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); - #endif -+#endif - #ifdef PHP_OUTPUT_NEWAPI - php_output_end_all(TSRMLS_C); - #else - php_end_ob_buffers(1 TSRMLS_CC); ---- a/sapi/milter/php_milter.c -+++ b/sapi/milter/php_milter.c -@@ -1109,7 +1109,11 @@ int main(int argc, char *argv[]) - } - SG(headers_sent) = 1; - SG(request_info).no_headers = 1; -+#if SUHOSIN_PATCH -+ php_printf("PHP with Suhosin-Patch %s (%s) (built: %s %s)\nCopyright (c) 1997-2014 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-2014 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); -+#endif - php_output_teardown(); - exit(1); - break; ---- php-5.5.0alpha1/win32/build/config.w32~ 2012-11-17 13:39:12.000000000 +0200 -+++ php-5.5.0alpha1/win32/build/config.w32 2012-11-17 13:48:11.720739542 +0200 -@@ -364,7 +364,7 @@ - zend_stream.c zend_iterators.c zend_interfaces.c zend_objects.c \ - zend_object_handlers.c zend_objects_API.c \ - zend_default_classes.c zend_execute.c zend_strtod.c zend_gc.c zend_closures.c \ -- zend_float.c zend_string.c zend_generators.c"); -+ zend_float.c zend_string.c zend_generators.c zend_canary.c zend_alloc_canary.c"); - - if (VCVERS == 1200) { - AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1); -@@ -385,6 +385,7 @@ ADD_FLAG("CFLAGS", "/D FD_SETSIZE=" + pa - - AC_DEFINE('HAVE_USLEEP', 1); - AC_DEFINE('HAVE_STRCOLL', 1); -+AC_DEFINE('SUHOSIN_PATCH', 1); - - /* For snapshot builders, where can we find the additional - * files that make up the snapshot template? */ ---- a/win32/build/config.w32.h.in -+++ b/win32/build/config.w32.h.in -@@ -150,6 +150,9 @@ - /* Win32 supports strcoll */ - #define HAVE_STRCOLL 1 - -+/* Suhosin Patch support */ -+#define SUHOSIN_PATCH 1 -+ - /* Win32 supports socketpair by the emulation in win32/sockets.c */ - #define HAVE_SOCKETPAIR 1 - #define HAVE_SOCKLEN_T 1 -- 2.46.0