diff options
author | Ondřej Surý <ondrej@sury.org> | 2012-05-31 10:55:48 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2012-05-31 10:55:48 +0200 |
commit | 90ceaa9e92fadfef4c21ec0f76063c4387beb561 (patch) | |
tree | 42c54fe576b4513fa12eb949ce67bda472411abc | |
parent | 01c525f668ecff08bea21c4ff22745b8f77e8c3a (diff) | |
download | php-90ceaa9e92fadfef4c21ec0f76063c4387beb561.tar.gz |
Imported Upstream version 5.4.4~rc2upstream/5.4.4_rc2
100 files changed, 1643 insertions, 715 deletions
@@ -1,6 +1,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -17 May 2012, PHP 5.4.4 RC1 +?? ??? 2012, PHP 5.4.4 + +- COM: + . Fixed bug #62146 com_dotnet cannot be built shared. (Johannes) - CLI Server: . Implemented FR #61977 (Need CLI web-server support for files with .htm & @@ -17,8 +20,11 @@ PHP NEWS - Core: . Fixed missing bound check in iptcparse(). (chris at chiappa.net) + . Fixed CVE-2012-2143. (Solar Designer) . Fixed bug #62005 (unexpected behavior when incrementally assigning to a member of a null object). (Laruence) + . Fixed bug #61998 (Using traits with method aliases appears to result in + crash during execution). (Dmitry) . Fixed bug #61978 (Object recursion not detected for classes that implement JsonSerializable). (Felipe) . Fixed bug #61991 (long overflow in realpath_cache_get()). (Anatoliy) @@ -43,19 +49,46 @@ PHP NEWS . Changed php://fd to be available only for CLI. - Phar: - . Fix bug #61065 (Secunia SA44335). (Rasmus) + . Fix bug #61065 (Secunia SA44335, CVE-2012-2386). (Rasmus) -- Reflection: - . Implemented FR #61602 (Allow access to the name of constant - used as function/method parameter's default value). (reeze.xia@gmail.com) +- Pgsql: + . Added pg_escape_identifier/pg_escape_literal. (Yasuo Ohgaki) -- FPM +- Fileinfo . Fixed bug #61812 (Uninitialised value used in libmagic). (Laruence, Gustavo) +- FPM + . Fixed bug #61045 (fpm don't send error log to fastcgi clients). (fat) + . Fixed bug #61835 (php-fpm is not allowed to run as root). (fat) + . Fixed bug #61295 (php-fpm should not fail with commented 'user' + for non-root start). (fat) + . Fixed bug #61839 (Unable to cross-compile PHP with --enable-fpm). (fat) + . Fixed bug #61026 (FPM pools can listen on the same address). (fat) + . Fixed bug #62033 (php-fpm exits with status 0 on some failures to start). + (fat) + . Fixed bug #62153 (when using unix sockets, multiples FPM instances + can be launched without errors). (fat) + . Fixed bug #62160 (Add process.priority to set nice(2) priorities). (fat) + . Fixed bug #61218 (FPM drops connection while receiving some binary values + in FastCGI requests). (fat) + +- Intl + . ResourceBundle constructor now accepts NULL for the first two arguments. + (Gustavo) + . Fixed bug #62082 (Memory corruption in internal function + get_icu_disp_value_src_php()). (Gustavo) + - Libxml: . Fixed bug #61617 (Libxml tests failed(ht is already destroyed)). (Laruence) + +- Sockets: + . Fixed bug #62025 (__ss_family was changed on AIX 5.3). (Felipe) + +- XML Writer: + . Fixed bug #62064 (memory leak in the XML Writer module). + (jean-pierre dot lozi at lip6 dot fr) - Zlib: . Fixed bug #61820 (using ob_gzhandler will complain about headers already @@ -37,9 +37,9 @@ PHP 5.4 UPGRADE NOTES ============================= - PHP 5.4 now checks at compile time if /dev/urandom or /dev/arandom - are present. If either is available, session.entropy_file now + are present. If either is available, session.entropy_file now defaults to that file and session.entropy_length defaults to 32. - This provides non-blocking entropy to session id generation. If you + This provides non-blocking entropy to session id generation. If you do not want extra entropy for your session ids, add: session.entropy_file= @@ -89,9 +89,9 @@ PHP 5.4 UPGRADE NOTES session.upload_progress.min_freq - Added a zend.multibyte directive as a replacement of the PHP compile time - configuration option --enable-zend-multibyte. Now the Zend Engine always + configuration option --enable-zend-multibyte. Now the Zend Engine always contains code for multibyte support, which can be enabled or disabled at - runtime. Note: It doesn't make a lot of sense to enable this option if + runtime. Note: It doesn't make a lot of sense to enable this option if ext/mbstring is not enabled, because most functionality is implemented by mbstrings callbacks. @@ -107,7 +107,7 @@ PHP 5.4 UPGRADE NOTES in a stream fashion (through php://input) without having it copied in memory multiple times. -- Added windows_show_crt_warning. This directive shows the CRT warnings when +- Added windows_show_crt_warning. This directive shows the CRT warnings when enabled. These warnings were displayed by default until now. It is disabled by default. @@ -162,7 +162,7 @@ PHP 5.4 UPGRADE NOTES - Non-numeric string offsets, e.g. $a['foo'] where $a is a string, now return false on isset() and true on empty(), and produce warning if - trying to use them. Offsets of types double, bool and null produce + trying to use them. Offsets of types double, bool and null produce notice. Numeric strings ($a['2']) still work as before. Note that offsets like '12.3' and '5 and a half' are considered @@ -207,7 +207,7 @@ PHP 5.4 UPGRADE NOTES - htmlentities() and htmlspecialchars() are stricter in the code units they accept for the asian encodings. For Big5-HKSCS, the octets 0x80 and 0xFF are - rejected. For GB2312/EUC-CN, the octets 0x8E, 0x8F, 0xA0 and 0xFF are + rejected. For GB2312/EUC-CN, the octets 0x8E, 0x8F, 0xA0 and 0xFF are rejected. For SJIS, the octets 0x80, 0xA0, 0xFD, 0xFE and 0xFF are rejected, except maybe after a valid starting byte. For EUC-JP, the octets 0xA0 and 0xFF are rejected. @@ -233,7 +233,7 @@ PHP 5.4 UPGRADE NOTES checks on the validity of the entities. Numerical entities are checked for a valid range (0 to 0x10FFFF); if the flag ENT_DISALLOWED is given, the validity of such numerical entity in the target document type is also - checked. Named entities are checked for necessary existence in the target + checked. Named entities are checked for necessary existence in the target document type instead of only checking whether they were constituted by alphanumeric characters. @@ -341,6 +341,8 @@ PHP 5.4 UPGRADE NOTES - Since 5.4.4, "php://fd" stream syntax is available only in CLI build. +- Since 5.4.5, resourcebundle_create() accepts null for the first two arguments. + ============================== 5. Changes to existing classes ============================== @@ -373,6 +375,9 @@ PHP 5.4 UPGRADE NOTES - FilesystemIterator, GlobIterator and (Recursive)DirectoryIterator now use the default stream context. +- Since 5.4.5, the constructor of ResourceBundle accepts NULL for the first two + arguments. + =========================== 7. Deprecated Functionality =========================== @@ -431,7 +436,7 @@ d. Removed hash algorithms a. Extensions no longer maintained - ext/sqlite is no longer part of the base distribution and has been moved - to PECL. Use sqlite3 or PDO_SQLITE instead. + to PECL. Use sqlite3 or PDO_SQLITE instead. b. Extensions with changed behavior @@ -485,7 +490,7 @@ b. Extensions with changed behavior =========================== - A REQUEST_TIME_FLOAT value returns a floating point number indicating the - time with microsecond precision. All SAPIs providing this value should be + time with microsecond precision. All SAPIs providing this value should be returning float and not time_t. - apache_child_terminate(), getallheaders(), apache_request_headers() @@ -610,6 +615,10 @@ c. New functions - mysqli_error_list() - mysqli_stmt_error_list() + - pgsql + - pg_escape_identifier() (5.4.4) + - pg_escape_literal() (5.4.4) + - Session: - session_register_shutdown() - session_status() diff --git a/Zend/tests/bug62097.phpt b/Zend/tests/bug62097.phpt new file mode 100644 index 000000000..07e93bfa8 --- /dev/null +++ b/Zend/tests/bug62097.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #62097: fix for bug #54547 is wrong for 32-bit machines +--SKIPIF-- +<?php +if (PHP_INT_MAX !== 2147483647) + die('skip for system with 32-bit wide longs only'); +--FILE-- +<?php +var_dump("02147483647" == "2147483647", + "02147483648" == "2147483648", + "09007199254740991" == "9007199254740991", + "09007199254740992" == "9007199254740992"); +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(false) diff --git a/Zend/tests/traits/bug61998.phpt b/Zend/tests/traits/bug61998.phpt new file mode 100644 index 000000000..612caa066 --- /dev/null +++ b/Zend/tests/traits/bug61998.phpt @@ -0,0 +1,68 @@ +--TEST-- +Bug #61998 (Using traits with method aliases appears to result in crash during execution) +--FILE-- +<?php +class Foo { + use T1 { + func as newFunc; + } + + public function func() { + echo "From Foo\n"; + } +} + +trait T1 { + public function func() { + echo "From T1\n"; + } +} + +class Bar { + public function func() { + echo "From Bar\n"; + } + public function func2() { + echo "From Bar\n"; + } + public function func3() { + echo "From Bar\n"; + } + use T1 { + func as newFunc; + func as func2; + } + use T2 { + func2 as newFunc2; + func2 as newFunc3; + func2 as func3; + } +} + +trait T2 { + public function func2() { + echo "From T2\n"; + } +} + +$f = new Foo(); + +$f->newFunc(); //from T1 +$f->func(); //from Foo + +$b = new Bar(); +$b->newFunc(); //from T1 +$b->func(); //from Bar +$b->func2(); //from Bar +$b->newFunc2(); //from T2 +$b->newFunc3(); //from T2 +$b->func3(); //from Bar +--EXPECTF-- +From T1 +From Foo +From T1 +From Bar +From Bar +From T2 +From T2 +From Bar diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 602b60041..28f98249d 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3619,6 +3619,7 @@ ZEND_API void zend_do_implement_trait(zend_class_entry *ce, zend_class_entry *tr } } ce->traits[ce->num_traits++] = trait; + trait->refcount++; } } /* }}} */ @@ -3870,8 +3871,8 @@ static int zend_traits_copy_functions(zend_function *fn TSRMLS_DC, int num_args, fn_copy = *fn; function_add_ref(&fn_copy); /* this function_name is never destroyed, because its refcount - greater than 1, classes are always destoyed in reverse order - and trait is declared early than this class */ + greater than 1 and classes are always destoyed before the + traits they use */ fn_copy.common.function_name = aliases[i]->alias; /* if it is 0, no modifieres has been changed */ @@ -4076,14 +4077,14 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{ size_t i; /* prepare copies of trait function tables for combination */ - function_tables = malloc(sizeof(HashTable*) * ce->num_traits); - resulting_table = (HashTable *) malloc(sizeof(HashTable)); + function_tables = emalloc(sizeof(HashTable*) * ce->num_traits); + resulting_table = (HashTable *)emalloc(sizeof(HashTable)); /* TODO: revisit this start size, may be its not optimal */ - zend_hash_init_ex(resulting_table, 10, NULL, NULL, 1, 0); + zend_hash_init_ex(resulting_table, 10, NULL, NULL, 0, 0); for (i = 0; i < ce->num_traits; i++) { - function_tables[i] = (HashTable *) malloc(sizeof(HashTable)); + function_tables[i] = (HashTable *)emalloc(sizeof(HashTable)); zend_hash_init_ex(function_tables[i], ce->traits[i]->function_table.nNumOfElements, NULL, NULL, 1, 0); if (ce->trait_precedences) { @@ -4116,14 +4117,14 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{ for (i = 0; i < ce->num_traits; i++) { /* zend_hash_destroy(function_tables[i]); */ zend_hash_graceful_destroy(function_tables[i]); - free(function_tables[i]); + efree(function_tables[i]); } - free(function_tables); + efree(function_tables); /* free temporary resulting table */ /* zend_hash_destroy(resulting_table); */ zend_hash_graceful_destroy(resulting_table); - free(resulting_table); + efree(resulting_table); } /* }}} */ diff --git a/Zend/zend_multibyte.c b/Zend/zend_multibyte.c index 9149fdcf0..379f50b01 100644 --- a/Zend/zend_multibyte.c +++ b/Zend/zend_multibyte.c @@ -168,7 +168,7 @@ ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(TSRMLS_D) ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size TSRMLS_DC) { if (CG(script_encoding_list)) { - efree(CG(script_encoding_list)); + free(CG(script_encoding_list)); } CG(script_encoding_list) = encoding_list; CG(script_encoding_list_size) = encoding_list_size; diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index 65fa85185..19fd71e76 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -215,6 +215,12 @@ ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC) void _destroy_zend_class_traits_info(zend_class_entry *ce) { if (ce->num_traits > 0 && ce->traits) { + size_t i; + for (i = 0; i < ce->num_traits; i++) { + if (ce->traits[i]) { + destroy_zend_class(&ce->traits[i]); + } + } efree(ce->traits); } diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 8d4baa6ac..dd3ee2d8c 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2041,7 +2041,13 @@ ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2) /* {{{ */ if ((ret1=is_numeric_string_ex(Z_STRVAL_P(s1), Z_STRLEN_P(s1), &lval1, &dval1, 0, &oflow1)) && (ret2=is_numeric_string_ex(Z_STRVAL_P(s2), Z_STRLEN_P(s2), &lval2, &dval2, 0, &oflow2))) { +#if ULONG_MAX == 0xFFFFFFFF + if (oflow1 != 0 && oflow1 == oflow2 && dval1 - dval2 == 0. && + ((oflow1 == 1 && dval1 > 9007199254740991. /*0x1FFFFFFFFFFFFF*/) + || (oflow1 == -1 && dval1 < -9007199254740991.))) { +#else if (oflow1 != 0 && oflow1 == oflow2 && dval1 - dval2 == 0.) { +#endif /* both values are integers overflown to the same side, and the * double comparison may have resulted in crucial accuracy lost */ goto string_cmp; @@ -3636,8 +3636,8 @@ ac_config_headers="$ac_config_headers main/php_config.h" PHP_MAJOR_VERSION=5 PHP_MINOR_VERSION=4 -PHP_RELEASE_VERSION=4 -PHP_EXTRA_VERSION="-RC1" +PHP_RELEASE_VERSION=5 +PHP_EXTRA_VERSION="-dev" PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION" PHP_VERSION_ID=`expr $PHP_MAJOR_VERSION \* 10000 + $PHP_MINOR_VERSION \* 100 + $PHP_RELEASE_VERSION` @@ -11598,6 +11598,18 @@ fi done + for ac_header in sysexits.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sysexits.h" "ac_cv_header_sysexits_h" "$ac_includes_default" +if test "x$ac_cv_header_sysexits_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYSEXITS_H 1 +_ACEOF + +fi + +done + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for prctl" >&5 @@ -11802,10 +11814,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext $as_echo_n "checking whether ptrace works... " >&6; } if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run test program while cross compiling -See \`config.log' for more details." "$LINENO" 5; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped (cross compiling)" >&5 +$as_echo "skipped (cross compiling)" >&6; } + else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -11960,10 +11972,10 @@ $as_echo "#define HAVE_MACH_VM_READ 1" >>confdefs.h $as_echo_n "checking for proc mem file... " >&6; } if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run test program while cross compiling -See \`config.log' for more details." "$LINENO" 5; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped (cross compiling)" >&5 +$as_echo "skipped (cross compiling)" >&6; } + else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -86485,6 +86497,44 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext $as_echo "#define HAVE_SOCKETS 1" >>confdefs.h + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for field ss_family in struct sockaddr_storage" >&5 +$as_echo_n "checking for field ss_family in struct sockaddr_storage... " >&6; } +if test "${ac_cv_ss_family+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include <sys/socket.h> +#include <sys/types.h> +#include <netdb.h> + +int +main () +{ +struct sockaddr_storage sa_store; sa_store.ss_family = AF_INET6; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_ss_family=yes +else + ac_cv_ss_family=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_ss_family" >&5 +$as_echo "$ac_cv_ss_family" >&6; } + + if test "$ac_cv_ss_family" = yes; then + +$as_echo "#define HAVE_SA_SS_FAMILY 1" >>confdefs.h + + fi + ext_builddir=ext/sockets ext_srcdir=$abs_srcdir/ext/sockets @@ -103763,7 +103813,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 103766 "configure" +#line 103816 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -105675,7 +105725,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 105678 "configure"' > conftest.$ac_ext + echo '#line 105728 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -107067,7 +107117,7 @@ else LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat > conftest.$ac_ext <<EOF -#line 107070 "configure" +#line 107120 "configure" #include "confdefs.h" int main() { ; return 0; } @@ -107225,11 +107275,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"configure:107228: $lt_compile\"" >&5) + (eval echo "\"configure:107278: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "configure:107232: \$? = $ac_status" >&5 + echo "configure:107282: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -107523,11 +107573,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"configure:107526: $lt_compile\"" >&5) + (eval echo "\"configure:107576: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "configure:107530: \$? = $ac_status" >&5 + echo "configure:107580: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -107627,11 +107677,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"configure:107630: $lt_compile\"" >&5) + (eval echo "\"configure:107680: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "configure:107634: \$? = $ac_status" >&5 + echo "configure:107684: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -108091,7 +108141,7 @@ _LT_EOF # Determine the default libpath from the value encoded in an empty executable. cat > conftest.$ac_ext <<EOF -#line 108094 "configure" +#line 108144 "configure" #include "confdefs.h" int main() { ; return 0; } @@ -108133,7 +108183,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi # Determine the default libpath from the value encoded in an empty executable. cat > conftest.$ac_ext <<EOF -#line 108136 "configure" +#line 108186 "configure" #include "confdefs.h" int main() { ; return 0; } @@ -109658,7 +109708,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 109661 "configure" +#line 109711 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -109758,7 +109808,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 109761 "configure" +#line 109811 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -110823,7 +110873,7 @@ case $host_os in # Determine the default libpath from the value encoded in an empty executable. cat > conftest.$ac_ext <<EOF -#line 110826 "configure" +#line 110876 "configure" #include "confdefs.h" int main() { ; return 0; } @@ -110866,7 +110916,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi # Determine the default libpath from the value encoded in an empty executable. cat > conftest.$ac_ext <<EOF -#line 110869 "configure" +#line 110919 "configure" #include "confdefs.h" int main() { ; return 0; } @@ -112118,11 +112168,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"configure:112121: $lt_compile\"" >&5) + (eval echo "\"configure:112171: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "configure:112125: \$? = $ac_status" >&5 + echo "configure:112175: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -112222,11 +112272,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"configure:112225: $lt_compile\"" >&5) + (eval echo "\"configure:112275: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "configure:112229: \$? = $ac_status" >&5 + echo "configure:112279: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized diff --git a/configure.in b/configure.in index 053a56fbd..1e8068992 100644 --- a/configure.in +++ b/configure.in @@ -119,8 +119,8 @@ int zend_sprintf(char *buffer, const char *format, ...); PHP_MAJOR_VERSION=5 PHP_MINOR_VERSION=4 -PHP_RELEASE_VERSION=4 -PHP_EXTRA_VERSION="-RC1" +PHP_RELEASE_VERSION=5 +PHP_EXTRA_VERSION="-dev" PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION" PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION` diff --git a/ext/com_dotnet/com_misc.c b/ext/com_dotnet/com_misc.c index 1158354ac..33bd6380f 100644 --- a/ext/com_dotnet/com_misc.c +++ b/ext/com_dotnet/com_misc.c @@ -42,7 +42,7 @@ void php_com_throw_exception(HRESULT code, char *message TSRMLS_DC) } } -PHPAPI void php_com_wrap_dispatch(zval *z, IDispatch *disp, +PHP_COM_DOTNET_API void php_com_wrap_dispatch(zval *z, IDispatch *disp, int codepage TSRMLS_DC) { php_com_dotnet_object *obj; @@ -65,7 +65,7 @@ PHPAPI void php_com_wrap_dispatch(zval *z, IDispatch *disp, z->value.obj.handlers = &php_com_object_handlers; } -PHPAPI void php_com_wrap_variant(zval *z, VARIANT *v, +PHP_COM_DOTNET_API void php_com_wrap_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC) { php_com_dotnet_object *obj; @@ -92,7 +92,7 @@ PHPAPI void php_com_wrap_variant(zval *z, VARIANT *v, /* this is a convenience function for fetching a particular * element from a (possibly multi-dimensional) safe array */ -PHPAPI int php_com_safearray_get_elem(VARIANT *array, VARIANT *dest, LONG dim1 TSRMLS_DC) +PHP_COM_DOTNET_API int php_com_safearray_get_elem(VARIANT *array, VARIANT *dest, LONG dim1 TSRMLS_DC) { UINT dims; LONG lbound, ubound; diff --git a/ext/com_dotnet/com_olechar.c b/ext/com_dotnet/com_olechar.c index 903cd9dec..e57c7343d 100644 --- a/ext/com_dotnet/com_olechar.c +++ b/ext/com_dotnet/com_olechar.c @@ -30,7 +30,7 @@ #include "php_com_dotnet_internal.h" -PHPAPI OLECHAR *php_com_string_to_olestring(char *string, uint string_len, int codepage TSRMLS_DC) +PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, uint string_len, int codepage TSRMLS_DC) { OLECHAR *olestring = NULL; DWORD flags = codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS; @@ -65,7 +65,7 @@ PHPAPI OLECHAR *php_com_string_to_olestring(char *string, uint string_len, int c return olestring; } -PHPAPI char *php_com_olestring_to_string(OLECHAR *olestring, uint *string_len, int codepage TSRMLS_DC) +PHP_COM_DOTNET_API char *php_com_olestring_to_string(OLECHAR *olestring, uint *string_len, int codepage TSRMLS_DC) { char *string; uint length = 0; diff --git a/ext/com_dotnet/com_persist.c b/ext/com_dotnet/com_persist.c index 233d4a1dc..7c035f6c4 100755 --- a/ext/com_dotnet/com_persist.c +++ b/ext/com_dotnet/com_persist.c @@ -268,7 +268,7 @@ static void istream_destructor(php_istream *stm TSRMLS_DC) } /* }}} */ -PHPAPI IStream *php_com_wrapper_export_stream(php_stream *stream TSRMLS_DC) +PHP_COM_DOTNET_API IStream *php_com_wrapper_export_stream(php_stream *stream TSRMLS_DC) { php_istream *stm = (php_istream*)CoTaskMemAlloc(sizeof(*stm)); diff --git a/ext/com_dotnet/com_typeinfo.c b/ext/com_dotnet/com_typeinfo.c index f0a845003..f57b97f0d 100644 --- a/ext/com_dotnet/com_typeinfo.c +++ b/ext/com_dotnet/com_typeinfo.c @@ -35,7 +35,7 @@ * b) a CLSID, major, minor e.g. "{00000200-0000-0010-8000-00AA006D2EA4},2,0" * c) a Type Library name e.g. "Microsoft OLE DB ActiveX Data Objects 1.0 Library" */ -PHPAPI ITypeLib *php_com_load_typelib(char *search_string, int codepage TSRMLS_DC) +PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codepage TSRMLS_DC) { ITypeLib *TL = NULL; char *strtok_buf, *major, *minor; @@ -153,7 +153,7 @@ PHPAPI ITypeLib *php_com_load_typelib(char *search_string, int codepage TSRMLS_D } /* Given a type-library, merge it into the current engine state */ -PHPAPI int php_com_import_typelib(ITypeLib *TL, int mode, int codepage TSRMLS_DC) +PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, int codepage TSRMLS_DC) { int i, j, interfaces; TYPEKIND pTKind; @@ -228,7 +228,7 @@ void php_com_typelibrary_dtor(void *pDest) ITypeLib_Release(*Lib); } -PHPAPI ITypeLib *php_com_load_typelib_via_cache(char *search_string, +PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string, int codepage, int *cached TSRMLS_DC) { ITypeLib **TLp; diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c index 10dba0fc3..2adccb588 100644 --- a/ext/com_dotnet/com_variant.c +++ b/ext/com_dotnet/com_variant.c @@ -98,7 +98,7 @@ bogus: } } -PHPAPI void php_com_variant_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC) +PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC) { OLECHAR *olestring; php_com_dotnet_object *obj; @@ -166,7 +166,7 @@ PHPAPI void php_com_variant_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_D } } -PHPAPI int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC) +PHP_COM_DOTNET_API int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC) { OLECHAR *olestring = NULL; int ret = SUCCESS; @@ -258,7 +258,7 @@ PHPAPI int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC } -PHPAPI int php_com_copy_variant(VARIANT *dstvar, VARIANT *srcvar TSRMLS_DC) +PHP_COM_DOTNET_API int php_com_copy_variant(VARIANT *dstvar, VARIANT *srcvar TSRMLS_DC) { int ret = SUCCESS; diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c index 7494d882e..c8e59f95c 100644 --- a/ext/com_dotnet/com_wrapper.c +++ b/ext/com_dotnet/com_wrapper.c @@ -578,7 +578,7 @@ static void disp_destructor(php_dispatchex *disp TSRMLS_DC) CoTaskMemFree(disp); } -PHPAPI IDispatch *php_com_wrapper_export_as_sink(zval *val, GUID *sinkid, +PHP_COM_DOTNET_API IDispatch *php_com_wrapper_export_as_sink(zval *val, GUID *sinkid, HashTable *id_to_name TSRMLS_DC) { php_dispatchex *disp = disp_constructor(val TSRMLS_CC); @@ -617,7 +617,7 @@ PHPAPI IDispatch *php_com_wrapper_export_as_sink(zval *val, GUID *sinkid, return (IDispatch*)disp; } -PHPAPI IDispatch *php_com_wrapper_export(zval *val TSRMLS_DC) +PHP_COM_DOTNET_API IDispatch *php_com_wrapper_export(zval *val TSRMLS_DC) { php_dispatchex *disp = NULL; diff --git a/ext/com_dotnet/php_com_dotnet.h b/ext/com_dotnet/php_com_dotnet.h index ddcd38132..96ea21ae6 100644 --- a/ext/com_dotnet/php_com_dotnet.h +++ b/ext/com_dotnet/php_com_dotnet.h @@ -28,6 +28,14 @@ extern zend_module_entry com_dotnet_module_entry; #include "TSRM.h" #endif +#ifdef PHP_WIN32 +# define PHP_COM_DOTNET_API __declspec(dllexport) +#elif defined(__GNUC__) && __GNUC__ >= 4 +# define PHP_COM_DOTNET_API __attribute__ ((visibility("default"))) +#else +# define PHP_COM_DOTNET_API +#endif + PHP_MINIT_FUNCTION(com_dotnet); PHP_MSHUTDOWN_FUNCTION(com_dotnet); PHP_RINIT_FUNCTION(com_dotnet); diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h index 8b9502079..f821bec97 100644 --- a/ext/com_dotnet/php_com_dotnet_internal.h +++ b/ext/com_dotnet/php_com_dotnet_internal.h @@ -84,9 +84,9 @@ zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *objec int php_com_saproxy_create(zval *com_object, zval *proxy_out, zval *index TSRMLS_DC); /* com_olechar.c */ -PHPAPI char *php_com_olestring_to_string(OLECHAR *olestring, +PHP_COM_DOTNET_API char *php_com_olestring_to_string(OLECHAR *olestring, uint *string_len, int codepage TSRMLS_DC); -PHPAPI OLECHAR *php_com_string_to_olestring(char *string, +PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, uint string_len, int codepage TSRMLS_DC); @@ -112,8 +112,8 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, char *name, int namelen, /* com_wrapper.c */ int php_com_wrapper_minit(INIT_FUNC_ARGS); -PHPAPI IDispatch *php_com_wrapper_export_as_sink(zval *val, GUID *sinkid, HashTable *id_to_name TSRMLS_DC); -PHPAPI IDispatch *php_com_wrapper_export(zval *val TSRMLS_DC); +PHP_COM_DOTNET_API IDispatch *php_com_wrapper_export_as_sink(zval *val, GUID *sinkid, HashTable *id_to_name TSRMLS_DC); +PHP_COM_DOTNET_API IDispatch *php_com_wrapper_export(zval *val TSRMLS_DC); /* com_persist.c */ int php_com_persist_minit(INIT_FUNC_ARGS); @@ -147,10 +147,10 @@ PHP_FUNCTION(variant_get_type); PHP_FUNCTION(variant_set_type); PHP_FUNCTION(variant_cast); -PHPAPI void php_com_variant_from_zval_with_type(VARIANT *v, zval *z, VARTYPE type, int codepage TSRMLS_DC); -PHPAPI void php_com_variant_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC); -PHPAPI int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC); -PHPAPI int php_com_copy_variant(VARIANT *dst, VARIANT *src TSRMLS_DC); +PHP_COM_DOTNET_API void php_com_variant_from_zval_with_type(VARIANT *v, zval *z, VARTYPE type, int codepage TSRMLS_DC); +PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC); +PHP_COM_DOTNET_API int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC); +PHP_COM_DOTNET_API int php_com_copy_variant(VARIANT *dst, VARIANT *src TSRMLS_DC); /* com_dotnet.c */ PHP_FUNCTION(com_dotnet_create_instance); @@ -159,17 +159,17 @@ void php_com_dotnet_mshutdown(TSRMLS_D); /* com_misc.c */ void php_com_throw_exception(HRESULT code, char *message TSRMLS_DC); -PHPAPI void php_com_wrap_dispatch(zval *z, IDispatch *disp, +PHP_COM_DOTNET_API void php_com_wrap_dispatch(zval *z, IDispatch *disp, int codepage TSRMLS_DC); -PHPAPI void php_com_wrap_variant(zval *z, VARIANT *v, +PHP_COM_DOTNET_API void php_com_wrap_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC); -PHPAPI int php_com_safearray_get_elem(VARIANT *array, VARIANT *dest, LONG dim1 TSRMLS_DC); +PHP_COM_DOTNET_API int php_com_safearray_get_elem(VARIANT *array, VARIANT *dest, LONG dim1 TSRMLS_DC); /* com_typeinfo.c */ -PHPAPI ITypeLib *php_com_load_typelib_via_cache(char *search_string, +PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string, int codepage, int *cached TSRMLS_DC); -PHPAPI ITypeLib *php_com_load_typelib(char *search_string, int codepage TSRMLS_DC); -PHPAPI int php_com_import_typelib(ITypeLib *TL, int mode, +PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codepage TSRMLS_DC); +PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, int codepage TSRMLS_DC); void php_com_typelibrary_dtor(void *pDest); ITypeInfo *php_com_locate_typeinfo(char *typelibname, php_com_dotnet_object *obj, char *dispname, int sink TSRMLS_DC); diff --git a/ext/curl/tests/bug61948-win32.phpt b/ext/curl/tests/bug61948-win32.phpt new file mode 100644 index 000000000..dc86526b7 --- /dev/null +++ b/ext/curl/tests/bug61948-win32.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction) +--SKIPIF-- +<?php if (!extension_loaded("curl")) print "skip"; +if(substr(PHP_OS, 0, 3) != 'WIN' ) + die("skip Not Valid for Linux"); +?> +--INI-- +open_basedir="c:/tmp" +--FILE-- +<?php + $ch = curl_init(); + var_dump(curl_setopt($ch, CURLOPT_COOKIEFILE, "")); + var_dump(curl_setopt($ch, CURLOPT_COOKIEFILE, "c:/tmp/foo")); + var_dump(curl_setopt($ch, CURLOPT_COOKIEFILE, "c:/xxx/bar")); + curl_close($ch); +?> +--EXPECTF-- +%a + +Warning: curl_setopt(): open_basedir restriction in effect. File(c:/tmp/foo) is not within the allowed path(s): (c:/tmp) in %sbug61948-win32.php on line %d +bool(false) + +Warning: curl_setopt(): open_basedir restriction in effect. File(c:/xxx/bar) is not within the allowed path(s): (c:/tmp) in %sbug61948-win32.php on line %d +bool(false) diff --git a/ext/curl/tests/bug61948.phpt b/ext/curl/tests/bug61948.phpt index a03fc3b60..23bbda7d5 100644 --- a/ext/curl/tests/bug61948.phpt +++ b/ext/curl/tests/bug61948.phpt @@ -1,7 +1,10 @@ --TEST-- Bug #61948 (CURLOPT_COOKIEFILE '' raises open_basedir restriction) --SKIPIF-- -<?php if (!extension_loaded("curl")) print "skip"; ?> +<?php if (!extension_loaded("curl")) print "skip"; +if(substr(PHP_OS, 0, 3) == 'WIN' ) + die("skip Not Valid for Windows"); +?> --INI-- open_basedir="/tmp" --FILE-- diff --git a/ext/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch index baeac1dc1..48a02360b 100644 --- a/ext/fileinfo/libmagic.patch +++ b/ext/fileinfo/libmagic.patch @@ -1,6 +1,6 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c ---- libmagic.orig/apprentice.c 2012-04-22 19:30:43.182305355 +0800 -+++ libmagic/apprentice.c 2012-04-22 19:28:57.346309536 +0800 +--- libmagic.orig/apprentice.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/apprentice.c 2012-04-22 18:57:16.215980866 +0200 @@ -29,6 +29,8 @@ * apprentice - make one pass through /etc/magic, learning its secrets. */ @@ -729,8 +729,8 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c m->str_flags = swap4(m->str_flags); } diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c ---- libmagic.orig/ascmagic.c 2012-04-22 19:30:43.182305355 +0800 -+++ libmagic/ascmagic.c 2012-04-22 19:28:57.330309533 +0800 +--- libmagic.orig/ascmagic.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/ascmagic.c 2012-04-22 18:57:16.215980866 +0200 @@ -139,10 +139,8 @@ /* malloc size is a conservative overestimate; could be improved, or at least realloced after conversion. */ @@ -755,8 +755,8 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c return rv; } diff -u libmagic.orig/cdf.c libmagic/cdf.c ---- libmagic.orig/cdf.c 2012-04-22 19:30:43.182305355 +0800 -+++ libmagic/cdf.c 2012-04-22 19:28:57.370309531 +0800 +--- libmagic.orig/cdf.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/cdf.c 2012-04-22 18:57:16.219978162 +0200 @@ -43,7 +43,17 @@ #include <err.h> #endif @@ -819,8 +819,8 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c (void)fprintf(stderr, "timestamp %s\n", buf); } else { diff -u libmagic.orig/cdf.h libmagic/cdf.h ---- libmagic.orig/cdf.h 2012-04-22 19:30:43.182305355 +0800 -+++ libmagic/cdf.h 2012-04-22 19:28:57.370309531 +0800 +--- libmagic.orig/cdf.h 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/cdf.h 2012-04-22 18:57:16.219978162 +0200 @@ -35,7 +35,7 @@ #ifndef _H_CDF_ #define _H_CDF_ @@ -857,8 +857,8 @@ diff -u libmagic.orig/cdf.h libmagic/cdf.h void cdf_swap_header(cdf_header_t *); void cdf_unpack_header(cdf_header_t *, char *); diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c ---- libmagic.orig/cdf_time.c 2012-04-22 19:30:43.182305355 +0800 -+++ libmagic/cdf_time.c 2012-04-22 19:28:57.326309537 +0800 +--- libmagic.orig/cdf_time.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/cdf_time.c 2012-04-22 18:57:16.219978162 +0200 @@ -96,7 +96,7 @@ } @@ -916,8 +916,8 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c static const char *ref = "Sat Apr 23 01:30:00 1977"; char *p, *q; diff -u libmagic.orig/compress.c libmagic/compress.c ---- libmagic.orig/compress.c 2012-04-22 19:30:43.182305355 +0800 -+++ libmagic/compress.c 2012-04-22 19:28:57.314309548 +0800 +--- libmagic.orig/compress.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/compress.c 2012-04-22 18:57:16.219978162 +0200 @@ -32,6 +32,7 @@ * uncompress(method, old, n, newch) - uncompress old into new, * using method, return sizeof new @@ -1079,8 +1079,8 @@ diff -u libmagic.orig/compress.c libmagic/compress.c -#endif +#endif /* if PHP_FILEINFO_UNCOMPRESS */ diff -u libmagic.orig/file.h libmagic/file.h ---- libmagic.orig/file.h 2012-04-22 19:30:43.186305188 +0800 -+++ libmagic/file.h 2012-04-22 19:49:58.922256776 +0800 +--- libmagic.orig/file.h 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/file.h 2012-04-22 18:57:16.219978162 +0200 @@ -33,11 +33,9 @@ #ifndef __file_h__ #define __file_h__ @@ -1252,8 +1252,8 @@ diff -u libmagic.orig/file.h libmagic/file.h + #endif /* __file_h__ */ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c ---- libmagic.orig/fsmagic.c 2012-04-22 19:30:43.186305188 +0800 -+++ libmagic/fsmagic.c 2012-04-22 19:28:57.298309521 +0800 +--- libmagic.orig/fsmagic.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/fsmagic.c 2012-04-22 18:57:16.219978162 +0200 @@ -59,27 +59,21 @@ # define minor(dev) ((dev) & 0xff) #endif @@ -1577,8 +1577,8 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c /* diff -u libmagic.orig/funcs.c libmagic/funcs.c ---- libmagic.orig/funcs.c 2012-04-22 19:30:43.186305188 +0800 -+++ libmagic/funcs.c 2012-04-22 19:28:57.370309531 +0800 +--- libmagic.orig/funcs.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/funcs.c 2012-04-22 18:57:16.219978162 +0200 @@ -41,52 +41,42 @@ #if defined(HAVE_WCTYPE_H) #include <wctype.h> @@ -1872,11 +1872,9 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c + return rep_cnt; } + -Only in libmagic.orig: funcs.c.orig -Only in libmagic.orig: funcs.c.rej diff -u libmagic.orig/magic.c libmagic/magic.c ---- libmagic.orig/magic.c 2012-04-22 19:30:43.186305188 +0800 -+++ libmagic/magic.c 2012-04-22 19:28:57.370309531 +0800 +--- libmagic.orig/magic.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/magic.c 2012-04-22 18:57:16.219978162 +0200 @@ -25,11 +25,6 @@ * SUCH DAMAGE. */ @@ -2253,8 +2251,8 @@ diff -u libmagic.orig/magic.c libmagic/magic.c public const char * magic_error(struct magic_set *ms) diff -u libmagic.orig/magic.h libmagic/magic.h ---- libmagic.orig/magic.h 2012-04-22 19:30:43.190305058 +0800 -+++ libmagic/magic.h 2012-04-22 19:28:57.326309537 +0800 +--- libmagic.orig/magic.h 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/magic.h 2012-04-22 18:57:16.219978162 +0200 @@ -85,6 +85,7 @@ const char *magic_getpath(const char *, int); @@ -2272,8 +2270,8 @@ diff -u libmagic.orig/magic.h libmagic/magic.h int magic_errno(magic_t); diff -u libmagic.orig/print.c libmagic/print.c ---- libmagic.orig/print.c 2012-04-22 19:30:43.190305058 +0800 -+++ libmagic/print.c 2012-04-22 19:28:57.326309537 +0800 +--- libmagic.orig/print.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/print.c 2012-05-29 14:34:03.770376387 +0200 @@ -29,6 +29,9 @@ * print.c - debugging printout routines */ @@ -2467,8 +2465,8 @@ diff -u libmagic.orig/print.c libmagic/print.c protected const char * diff -u libmagic.orig/readcdf.c libmagic/readcdf.c ---- libmagic.orig/readcdf.c 2012-04-22 19:30:43.190305058 +0800 -+++ libmagic/readcdf.c 2012-04-22 19:28:57.326309537 +0800 +--- libmagic.orig/readcdf.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/readcdf.c 2012-04-22 18:57:16.219978162 +0200 @@ -30,7 +30,11 @@ #endif @@ -2515,8 +2513,8 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c if ((ec = strchr(c, '\n')) != NULL) *ec = '\0'; diff -u libmagic.orig/readelf.c libmagic/readelf.c ---- libmagic.orig/readelf.c 2012-04-22 19:30:43.190305058 +0800 -+++ libmagic/readelf.c 2012-04-22 19:28:57.378309534 +0800 +--- libmagic.orig/readelf.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/readelf.c 2012-04-22 18:57:16.219978162 +0200 @@ -49,7 +49,7 @@ off_t, int *, int); private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, @@ -2672,8 +2670,8 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c if (fstat(fd, &st) == -1) { diff -u libmagic.orig/softmagic.c libmagic/softmagic.c ---- libmagic.orig/softmagic.c 2012-04-22 19:30:43.194304945 +0800 -+++ libmagic/softmagic.c 2012-04-22 19:28:57.286309597 +0800 +--- libmagic.orig/softmagic.c 2012-05-29 14:40:41.710960045 +0200 ++++ libmagic/softmagic.c 2012-05-29 14:34:31.900417647 +0200 @@ -41,6 +41,11 @@ #include <stdlib.h> #include <time.h> @@ -2860,7 +2858,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c } } -@@ -1669,6 +1642,65 @@ +@@ -1669,6 +1642,42 @@ return file_strncmp(a, b, len, flags); } @@ -2876,29 +2874,6 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c + + for (i=0; i<Z_STRLEN_P(pattern); i++, j++) { + switch (Z_STRVAL_P(pattern)[i]) { -+ case '?': -+ t[j] = '.'; -+ break; -+ case '*': -+ t[j++] = '.'; -+ t[j] = '*'; -+ break; -+ case '.': -+ t[j++] = '\\'; -+ t[j] = '.'; -+ break; -+ case '\\': -+ t[j++] = '\\'; -+ t[j] = '\\'; -+ break; -+ case '(': -+ t[j++] = '\\'; -+ t[j] = '('; -+ break; -+ case ')': -+ t[j++] = '\\'; -+ t[j] = ')'; -+ break; + case '~': + t[j++] = '\\'; + t[j] = '~'; @@ -2926,7 +2901,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c private int magiccheck(struct magic_set *ms, struct magic *m) { -@@ -1825,67 +1857,163 @@ +@@ -1825,67 +1834,163 @@ break; } case FILE_REGEX: { @@ -2937,23 +2912,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c - if (ms->search.s == NULL) - return 0; - -+ zval *pattern; -+ int options = 0; -+ pcre_cache_entry *pce; -+ TSRMLS_FETCH(); -+ -+ MAKE_STD_ZVAL(pattern); -+ ZVAL_STRINGL(pattern, (char *)m->value.s, m->vallen, 0); -+ -+ options |= PCRE_MULTILINE; -+ -+ if (m->str_flags & STRING_IGNORE_CASE) { -+ options |= PCRE_CASELESS; -+ } -+ -+ convert_libmagic_pattern(pattern, options); -+ - l = 0; +- l = 0; - rc = regcomp(&rx, m->value.s, - REG_EXTENDED|REG_NEWLINE| - ((m->str_flags & STRING_IGNORE_CASE) ? REG_ICASE : 0)); @@ -2970,6 +2929,23 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c - size_t l = ms->search.s_len - 1; - char c = ms->search.s[l]; - ((char *)(intptr_t)ms->search.s)[l] = '\0'; ++ zval *pattern; ++ int options = 0; ++ pcre_cache_entry *pce; ++ TSRMLS_FETCH(); ++ ++ MAKE_STD_ZVAL(pattern); ++ ZVAL_STRINGL(pattern, (char *)m->value.s, m->vallen, 0); ++ ++ options |= PCRE_MULTILINE; ++ ++ if (m->str_flags & STRING_IGNORE_CASE) { ++ options |= PCRE_CASELESS; ++ } ++ ++ convert_libmagic_pattern(pattern, options); ++ ++ l = v = 0; +#if (PHP_MAJOR_VERSION < 6) + if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern) TSRMLS_CC)) == NULL) { #else diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c index 648f64169..f9c2836dd 100644 --- a/ext/fileinfo/libmagic/softmagic.c +++ b/ext/fileinfo/libmagic/softmagic.c @@ -1654,29 +1654,6 @@ convert_libmagic_pattern(zval *pattern, int options) for (i=0; i<Z_STRLEN_P(pattern); i++, j++) { switch (Z_STRVAL_P(pattern)[i]) { - case '?': - t[j] = '.'; - break; - case '*': - t[j++] = '.'; - t[j] = '*'; - break; - case '.': - t[j++] = '\\'; - t[j] = '.'; - break; - case '\\': - t[j++] = '\\'; - t[j] = '\\'; - break; - case '(': - t[j++] = '\\'; - t[j] = '('; - break; - case ')': - t[j++] = '\\'; - t[j] = ')'; - break; case '~': t[j++] = '\\'; t[j] = '~'; @@ -1873,7 +1850,7 @@ magiccheck(struct magic_set *ms, struct magic *m) convert_libmagic_pattern(pattern, options); - l = 0; + l = v = 0; #if (PHP_MAJOR_VERSION < 6) if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern) TSRMLS_CC)) == NULL) { #else diff --git a/ext/fileinfo/tests/finfo_file_002.phpt b/ext/fileinfo/tests/finfo_file_002.phpt index 9ed19a976..3593233c3 100644 --- a/ext/fileinfo/tests/finfo_file_002.phpt +++ b/ext/fileinfo/tests/finfo_file_002.phpt @@ -18,9 +18,11 @@ ksort($results); var_dump($results); ?> --EXPECTF-- -array(6) { +array(7) { ["%s/resources/dir.zip"]=> string(15) "application/zip" + ["%s/resources/test.awk"]=> + string(10) "text/plain" ["%s/resources/test.bmp"]=> string(14) "image/x-ms-bmp" ["%s/resources/test.gif"]=> diff --git a/ext/fileinfo/tests/finfo_file_regex-win32.phpt b/ext/fileinfo/tests/finfo_file_regex-win32.phpt new file mode 100644 index 000000000..1eda48c4d --- /dev/null +++ b/ext/fileinfo/tests/finfo_file_regex-win32.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test finfo_file() function : regex rules +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip.. only for Windows'); +} +?> +--FILE-- +<?php +/** + * Works with the unix file command: + * $ file -m magic resources/test.awk + * resources/test.awk: awk script, ASCII text + */ +$magicFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic'; +$finfo = finfo_open( FILEINFO_MIME, $magicFile ); + +echo "*** Testing finfo_file() : regex rules ***\n"; + +// Calling finfo_file() with all possible arguments +$file = __DIR__ . '/resources/test.awk'; +var_dump( finfo_file( $finfo, $file ) ); +var_dump( finfo_file( $finfo, $file, FILEINFO_CONTINUE ) ); + +// Windows uses libfileinfo 1.0.5-dev +// this may be causing the slightly different output from the first +// finfo_file() call + +?> +===DONE=== +--EXPECTF-- +*** Testing finfo_file() : regex rules *** +string(10) "text/plain" +string(22) "awk script, ASCII text" +===DONE=== diff --git a/ext/fileinfo/tests/finfo_file_regex.phpt b/ext/fileinfo/tests/finfo_file_regex.phpt new file mode 100644 index 000000000..ee4c8b0b7 --- /dev/null +++ b/ext/fileinfo/tests/finfo_file_regex.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test finfo_file() function : regex rules +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. only for Non Windows Systems'); +} +?> +--FILE-- +<?php +/** + * Works with the unix file command: + * $ file -m magic resources/test.awk + * resources/test.awk: awk script, ASCII text + */ +$magicFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic'; +$finfo = finfo_open( FILEINFO_MIME, $magicFile ); + +echo "*** Testing finfo_file() : regex rules ***\n"; + +// Calling finfo_file() with all possible arguments +$file = __DIR__ . '/resources/test.awk'; +var_dump( finfo_file( $finfo, $file ) ); +var_dump( finfo_file( $finfo, $file, FILEINFO_CONTINUE ) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing finfo_file() : regex rules *** +string(28) "text/plain; charset=us-ascii" +string(22) "awk script, ASCII text" +===DONE=== diff --git a/ext/fileinfo/tests/finfo_open_error-win32.phpt b/ext/fileinfo/tests/finfo_open_error-win32.phpt new file mode 100644 index 000000000..bd50327b2 --- /dev/null +++ b/ext/fileinfo/tests/finfo_open_error-win32.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test finfo_open() function : error functionality +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); +if(substr(PHP_OS, 0, 3) != 'WIN' ) + die("skip Not Valid for Linux"); +?> +--FILE-- +<?php +/* Prototype : resource finfo_open([int options [, string arg]]) + * Description: Create a new fileinfo resource. + * Source code: ext/fileinfo/fileinfo.c + * Alias to functions: + */ + +$magicFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic'; + +echo "*** Testing finfo_open() : error functionality ***\n"; + +var_dump( finfo_open( FILEINFO_MIME, 'foobarfile' ) ); +var_dump( finfo_open( array(), $magicFile ) ); +var_dump( finfo_open( FILEINFO_MIME, $magicFile, 'extraArg' ) ); +var_dump( finfo_open( PHP_INT_MAX - 1, $magicFile ) ); +var_dump( finfo_open( 'foobar' ) ); + +var_dump( new finfo('foobar') ); + +?> +===DONE=== +--EXPECTF-- +*** Testing finfo_open() : error functionality *** +bool(false) + +Warning: finfo_open() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: finfo_open() expects at most 2 parameters, 3 given in %s on line %d +bool(false) +resource(%d) of type (file_info) + +Warning: finfo_open() expects parameter 1 to be long, %unicode_string_optional% given in %s on line %d +bool(false) + +Warning: finfo::finfo() expects parameter 1 to be long, %unicode_string_optional% given in %s on line %d +NULL +===DONE=== diff --git a/ext/fileinfo/tests/finfo_open_error.phpt b/ext/fileinfo/tests/finfo_open_error.phpt index 19ae7a601..5d1eff597 100644 --- a/ext/fileinfo/tests/finfo_open_error.phpt +++ b/ext/fileinfo/tests/finfo_open_error.phpt @@ -1,7 +1,10 @@ --TEST-- Test finfo_open() function : error functionality --SKIPIF-- -<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +<?php require_once(dirname(__FILE__) . '/skipif.inc'); +if(substr(PHP_OS, 0, 3) == 'WIN' ) + die("skip Not Valid for Windows"); +?> --FILE-- <?php /* Prototype : resource finfo_open([int options [, string arg]]) diff --git a/ext/fileinfo/tests/resources/test.awk b/ext/fileinfo/tests/resources/test.awk new file mode 100644 index 000000000..e000d5041 --- /dev/null +++ b/ext/fileinfo/tests/resources/test.awk @@ -0,0 +1 @@ +BEGIN { print "START" } diff --git a/ext/gmp/tests/022-win32.phpt b/ext/gmp/tests/022-win32.phpt new file mode 100644 index 000000000..7abb0e82b --- /dev/null +++ b/ext/gmp/tests/022-win32.phpt @@ -0,0 +1,90 @@ +--TEST-- +gmp_gcdext() basic tests +--SKIPIF-- +<?php if (!extension_loaded("gmp")) print "skip"; +if(substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip windows only test'); +} +?> +--FILE-- +<?php + +$n = gmp_init("34293864345"); +$n1 = gmp_init("23434293864345"); + +$a = array( + array(123,45), + array(4341,9734), + array(23487,333), + array(-234234,-123123), + array(-100,-2234), + array(345,"34587345"), + array(345,"0"), + array("345556456",345873), + array("34545345556456","323432445873"), + array($n, $n1), + ); + +foreach ($a as $val) { + $r = gmp_gcdext($val[0],$val[1]); + var_dump(gmp_strval($r['g'])); + var_dump(gmp_strval($r['s'])); + var_dump(gmp_strval($r['t'])); +} + +var_dump(gmp_gcdext($val[0],array())); +var_dump(gmp_gcdext(array(),array())); +var_dump(gmp_gcdext(array(),array(),1)); +var_dump(gmp_gcdext(array())); +var_dump(gmp_gcdext()); + +echo "Done\n"; +?> +--EXPECTF-- +string(1) "3" +string(2) "41" +string(4) "-112" +string(1) "1" +string(4) "-805" +string(3) "359" +string(1) "3" +string(2) "32" +string(5) "-2257" +string(4) "3003" +string(3) "-10" +string(2) "19" +string(1) "2" +string(2) "67" +string(2) "-3" +string(2) "15" +string(7) "-601519" +string(1) "6" +string(3) "345" +string(1) "1" +string(1) "0" +string(1) "1" +string(5) "84319" +string(9) "-84241831" +string(1) "1" +string(12) "167180205823" +string(15) "-17856272782919" +string(3) "195" +string(15) "-23387298979862" +string(11) "34225091793" + +Warning: gmp_gcdext(): Unable to convert variable to GMP - wrong type in %s on line %d +bool(false) + +Warning: gmp_gcdext(): Unable to convert variable to GMP - wrong type in %s on line %d +bool(false) + +Warning: gmp_gcdext() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +Warning: gmp_gcdext() expects exactly 2 parameters, 1 given in %s on line %d +NULL + +Warning: gmp_gcdext() expects exactly 2 parameters, 0 given in %s on line %d +NULL +Done + diff --git a/ext/gmp/tests/022.phpt b/ext/gmp/tests/022.phpt index 805c9b675..f699e8283 100644 --- a/ext/gmp/tests/022.phpt +++ b/ext/gmp/tests/022.phpt @@ -1,7 +1,11 @@ --TEST-- gmp_gcdext() basic tests --SKIPIF-- -<?php if (!extension_loaded("gmp")) print "skip"; ?> +<?php if (!extension_loaded("gmp")) print "skip"; +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. only for Non Windows Systems'); +} +?> --FILE-- <?php diff --git a/ext/gmp/tests/gmp_nextprime-win32.phpt b/ext/gmp/tests/gmp_nextprime-win32.phpt new file mode 100644 index 000000000..e725315a1 --- /dev/null +++ b/ext/gmp/tests/gmp_nextprime-win32.phpt @@ -0,0 +1,45 @@ +--TEST-- +gmp_nextprime() +--SKIPIF-- +<?php if (!extension_loaded("gmp")) print "skip"; +if(substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip windows only test'); +} +?> +--FILE-- +<?php + +$n = gmp_nextprime(-1); +var_dump(gmp_strval($n)); +$n = gmp_nextprime(0); +var_dump(gmp_strval($n)); +$n = gmp_nextprime(-1000); +var_dump(gmp_strval($n)); +$n = gmp_nextprime(1000); +var_dump(gmp_strval($n)); +$n = gmp_nextprime(100000); +var_dump(gmp_strval($n)); +$n = gmp_nextprime(array()); +var_dump(gmp_strval($n)); +$n = gmp_nextprime(""); +var_dump(gmp_strval($n)); +$n = gmp_nextprime(new stdclass()); +var_dump(gmp_strval($n)); + +echo "Done\n"; +?> +--EXPECTF-- +string(1) "2" +string(1) "2" +string(4) "-997" +string(4) "1009" +string(6) "100003" + +Warning: gmp_nextprime(): Unable to convert variable to GMP - wrong type in %s on line %d +string(1) "0" +string(1) "0" + +Warning: gmp_nextprime(): Unable to convert variable to GMP - wrong type in %s on line %d +string(1) "0" +Done + diff --git a/ext/gmp/tests/gmp_nextprime.phpt b/ext/gmp/tests/gmp_nextprime.phpt index 65506ce13..623ccbed0 100644 --- a/ext/gmp/tests/gmp_nextprime.phpt +++ b/ext/gmp/tests/gmp_nextprime.phpt @@ -1,7 +1,11 @@ --TEST-- gmp_nextprime() --SKIPIF-- -<?php if (!extension_loaded("gmp")) print "skip"; ?> +<?php if (!extension_loaded("gmp")) print "skip"; +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. only for Non Windows Systems'); +} +?> --FILE-- <?php diff --git a/ext/intl/collator/collator_sort.c b/ext/intl/collator/collator_sort.c index a871c90a8..0785111c9 100755 --- a/ext/intl/collator/collator_sort.c +++ b/ext/intl/collator/collator_sort.c @@ -594,6 +594,8 @@ PHP_FUNCTION( collator_get_sort_key ) RETURN_FALSE; } + /* ucol_getSortKey is exception in that the key length includes the + * NUL terminator*/ key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, key, 0); if(!key_len) { efree( ustr ); @@ -605,7 +607,7 @@ PHP_FUNCTION( collator_get_sort_key ) if(!key_len) { RETURN_FALSE; } - RETURN_STRINGL((char *)key, key_len, 0); + RETURN_STRINGL((char *)key, key_len - 1, 0); } /* }}} */ diff --git a/ext/intl/dateformat/dateformat.c b/ext/intl/dateformat/dateformat.c index 6f7432254..b399a39fc 100755 --- a/ext/intl/dateformat/dateformat.c +++ b/ext/intl/dateformat/dateformat.c @@ -99,17 +99,46 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS) } INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value); + + if (calendar != UCAL_TRADITIONAL && calendar != UCAL_GREGORIAN) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: " + "invalid value for calendar type; it must be one of " + "IntlDateFormatter::TRADITIONAL (locale's default calendar) " + "or IntlDateFormatter::GREGORIAN", 0 TSRMLS_CC); + goto error; + } + DATE_FORMAT_METHOD_FETCH_OBJECT; + + if (DATE_FORMAT_OBJECT(dfo) != NULL) { + intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, + "datefmt_create: cannot call constructor twice", 0 TSRMLS_CC); + return; + } + /* Convert pattern (if specified) to UTF-16. */ if( pattern_str && pattern_str_len>0 ){ - intl_convert_utf8_to_utf16(&svalue, &slength, pattern_str, pattern_str_len, &INTL_DATA_ERROR_CODE(dfo)); - INTL_CTOR_CHECK_STATUS(dfo, "datefmt_create: error converting pattern to UTF-16"); + intl_convert_utf8_to_utf16(&svalue, &slength, + pattern_str, pattern_str_len, &INTL_DATA_ERROR_CODE(dfo)); + if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { + /* object construction -> only set global error */ + intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: " + "error converting pattern to UTF-16", 0 TSRMLS_CC); + goto error; + } } + + /* resources allocated from now on */ /* Convert pattern (if specified) to UTF-16. */ if( timezone_str && timezone_str_len >0 ){ - intl_convert_utf8_to_utf16(&timezone_utf16, &timezone_utf16_len, timezone_str, timezone_str_len, &INTL_DATA_ERROR_CODE(dfo)); - INTL_CTOR_CHECK_STATUS(dfo, "datefmt_create: error converting timezone_str to UTF-16" ); + intl_convert_utf8_to_utf16(&timezone_utf16, &timezone_utf16_len, + timezone_str, timezone_str_len, &INTL_DATA_ERROR_CODE(dfo)); + if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { + intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: " + "error converting timezone_str to UTF-16", 0 TSRMLS_CC); + goto error; + } } if(locale_len == 0) { @@ -122,25 +151,25 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS) DATE_FORMAT_OBJECT(dfo) = udat_open(time_type, date_type, locale, timezone_utf16, timezone_utf16_len, svalue, slength, &INTL_DATA_ERROR_CODE(dfo)); } - /* Set the calendar if passed */ - if(!U_FAILURE(INTL_DATA_ERROR_CODE(dfo)) && calendar) { - ucal_obj = ucal_open( timezone_utf16, timezone_utf16_len, locale, calendar, &INTL_DATA_ERROR_CODE(dfo) ); - if(!U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { - udat_setCalendar( DATE_FORMAT_OBJECT(dfo), ucal_obj ); + if (!U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { + if (calendar != UCAL_TRADITIONAL) { + ucal_obj = ucal_open(timezone_utf16, timezone_utf16_len, locale, + calendar, &INTL_DATA_ERROR_CODE(dfo)); + if (!U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { + udat_setCalendar(DATE_FORMAT_OBJECT(dfo), ucal_obj); + ucal_close(ucal_obj); + } else { + intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create" + ": error opening calendar", 0 TSRMLS_CC); + goto error; + } } - } - - if(svalue) - { - efree(svalue); - } - if(timezone_utf16) - { - efree(timezone_utf16); + } else { + intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: date " + "formatter creation failed", 0 TSRMLS_CC); + goto error; } - INTL_CTOR_CHECK_STATUS(dfo, "datefmt_create: date formatter creation failed"); - /* Set the class variables */ dfo->date_type = date_type; dfo->time_type = time_type; @@ -148,6 +177,19 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS) if( timezone_str && timezone_str_len > 0){ dfo->timezone_id = estrndup( timezone_str, timezone_str_len); } + +error: + if (svalue) { + efree(svalue); + } + if (timezone_utf16) { + efree(timezone_utf16); + } + if (U_FAILURE(intl_error_get_code(NULL TSRMLS_CC))) { + /* free_object handles partially constructed instances fine */ + zval_dtor(return_value); + RETVAL_NULL(); + } } /* }}} */ @@ -169,6 +211,8 @@ PHP_FUNCTION( datefmt_create ) */ PHP_METHOD( IntlDateFormatter, __construct ) { + /* return_value param is being changed, therefore we will always return + * NULL here */ return_value = getThis(); datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU); } diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c index 692e2f80b..475bbe418 100755 --- a/ext/intl/grapheme/grapheme_string.c +++ b/ext/intl/grapheme/grapheme_string.c @@ -822,6 +822,7 @@ PHP_FUNCTION(grapheme_extract) } else { /* initialize next */ + zval_dtor(next); ZVAL_LONG(next, lstart); } } diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c index 39d162a51..1707c69f9 100755 --- a/ext/intl/locale/locale_methods.c +++ b/ext/intl/locale/locale_methods.c @@ -527,7 +527,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME /* Get the disp_value for the given locale */ do{ - disp_name = erealloc( disp_name , buflen ); + disp_name = erealloc( disp_name , buflen * sizeof(UChar) ); disp_name_len = buflen; if( strcmp(tag_name , LOC_LANG_TAG)==0 ){ @@ -542,6 +542,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME buflen = uloc_getDisplayName ( mod_loc_name , disp_loc_name , disp_name , disp_name_len , &status); } + /* U_STRING_NOT_TERMINATED_WARNING is admissible here; don't look for it */ if( U_FAILURE( status ) ) { if( status == U_BUFFER_OVERFLOW_ERROR ) @@ -1562,11 +1563,11 @@ PHP_FUNCTION(locale_lookup) /* }}} */ /* {{{ proto string Locale::acceptFromHttp(string $http_accept) -* Tries to find out best available locale based on HTTP “Accept-Language” header +* Tries to find out best available locale based on HTTP �Accept-Language� header */ /* }}} */ /* {{{ proto string locale_accept_from_http(string $http_accept) -* Tries to find out best available locale based on HTTP “Accept-Language” header +* Tries to find out best available locale based on HTTP �Accept-Language� header */ PHP_FUNCTION(locale_accept_from_http) { diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index 5471e5b3f..1205450c4 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -91,7 +91,7 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS) intl_error_reset( NULL TSRMLS_CC ); - if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", + if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s!s!|b", &locale, &locale_len, &bundlename, &bundlename_len, &fallback ) == FAILURE ) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, @@ -101,6 +101,10 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS) } INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value); + + if (locale == NULL) { + locale = INTL_G(default_locale); + } if (fallback) { rb->me = ures_open(bundlename, locale, &INTL_DATA_ERROR_CODE(rb)); @@ -110,13 +114,17 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS) INTL_CTOR_CHECK_STATUS(rb, "resourcebundle_ctor: Cannot load libICU resource bundle"); - if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING || INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) { - intl_errors_set_code( NULL, INTL_DATA_ERROR_CODE(rb) TSRMLS_CC ); - spprintf( &pbuf, 0, "resourcebundle_ctor: Cannot load libICU resource '%s' without fallback from %s to %s", - bundlename, locale, ures_getLocaleByType( rb->me, ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(rb)) ); - intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf, 1 TSRMLS_CC ); + if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING || + INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) { + intl_errors_set_code(NULL, INTL_DATA_ERROR_CODE(rb) TSRMLS_CC); + spprintf(&pbuf, 0, "resourcebundle_ctor: Cannot load libICU resource " + "'%s' without fallback from %s to %s", + bundlename ? bundlename : "(default data)", locale, + ures_getLocaleByType( + rb->me, ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(rb))); + intl_errors_set_custom_msg(INTL_DATA_ERROR_P(rb), pbuf, 1 TSRMLS_CC); efree(pbuf); - zval_dtor( return_value ); + zval_dtor(return_value); RETURN_NULL(); } } @@ -427,6 +435,8 @@ void resourcebundle_register_class( TSRMLS_D ) ResourceBundle_object_handlers.clone_obj = NULL; /* ICU ResourceBundle has no clone implementation */ ResourceBundle_object_handlers.read_dimension = resourcebundle_array_get; ResourceBundle_object_handlers.count_elements = resourcebundle_array_count; + + zend_class_implements(ResourceBundle_ce_ptr TSRMLS_CC, 1, zend_ce_traversable); } /* }}} */ diff --git a/ext/intl/tests/bug59597_64.phpt b/ext/intl/tests/bug59597_64.phpt index 4b96bf72e..f96c72da5 100644 --- a/ext/intl/tests/bug59597_64.phpt +++ b/ext/intl/tests/bug59597_64.phpt @@ -15,7 +15,7 @@ $value = $formatter->parse('2147483650', \NumberFormatter::TYPE_INT64); var_dump($value); ?> ---EXPECTREGEX-- +--EXPECT-- int(2147483647) int(2147483650) diff --git a/ext/intl/tests/bug62017.phpt b/ext/intl/tests/bug62017.phpt new file mode 100644 index 000000000..13c4fe5df --- /dev/null +++ b/ext/intl/tests/bug62017.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #62017: datefmt_create with incorrectly encoded timezone leaks pattern +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set('intl.error_level', E_WARNING); +var_dump( + datefmt_create('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "\xFF", + IntlDateFormatter::GREGORIAN, 'a')); +var_dump( + new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon", + IntlDateFormatter::GREGORIAN, "\x80")); +--EXPECTF-- +Warning: datefmt_create(): datefmt_create: error converting timezone_str to UTF-16 in %s on line %d +NULL + +Warning: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %s on line %d +NULL + diff --git a/ext/intl/tests/bug62070.phpt b/ext/intl/tests/bug62070.phpt new file mode 100644 index 000000000..a466b05c2 --- /dev/null +++ b/ext/intl/tests/bug62070.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #62070: Collator::getSortKey() returns garbage +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +$s1 = 'Hello'; + +$coll = collator_create('en_US'); +$res = collator_get_sort_key($coll, $s1); + +echo urlencode($res); +--EXPECT-- +5%2F%3D%3DC%01%09%01%8F%08 diff --git a/ext/intl/tests/bug62081.phpt b/ext/intl/tests/bug62081.phpt new file mode 100644 index 000000000..7d9e2cec4 --- /dev/null +++ b/ext/intl/tests/bug62081.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #62081: IntlDateFormatter leaks memory if called twice +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set('intl.error_level', E_WARNING); +$x = new IntlDateFormatter(1,1,1,1,1); +var_dump($x->__construct(1,1,1,1,1)); +--EXPECTF-- +Warning: IntlDateFormatter::__construct(): datefmt_create: cannot call constructor twice in %s on line %d +NULL diff --git a/ext/intl/tests/bug62082.phpt b/ext/intl/tests/bug62082.phpt new file mode 100644 index 000000000..e6ca73e30 --- /dev/null +++ b/ext/intl/tests/bug62082.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #62082: Memory corruption in internal get_icu_disp_value_src_php() +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +var_dump(locale_get_display_name(str_repeat("a", 300), null)); +var_dump(locale_get_display_name(str_repeat("a", 512), null)); +var_dump(locale_get_display_name(str_repeat("a", 600), null)); +--EXPECT-- +string(300) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +string(512) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +string(600) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" diff --git a/ext/intl/tests/bug62083.phpt b/ext/intl/tests/bug62083.phpt new file mode 100644 index 000000000..4baa5c5e9 --- /dev/null +++ b/ext/intl/tests/bug62083.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #62083: grapheme_extract() leaks memory +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +$arr1 = array(); +var_dump(grapheme_extract(-1, -1, -1,-1, $arr1)); +--EXPECT-- +bool(false) diff --git a/ext/intl/tests/dateformat_calendars.phpt b/ext/intl/tests/dateformat_calendars.phpt new file mode 100644 index 000000000..27f380c71 --- /dev/null +++ b/ext/intl/tests/dateformat_calendars.phpt @@ -0,0 +1,45 @@ +--TEST-- +IntlDateFormatter, calendars and time zone +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$fmt1 = new IntlDateFormatter('en_US', + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + IntlDateFormatter::TRADITIONAL); +$fmt2 = new IntlDateFormatter('en_US', + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + IntlDateFormatter::GREGORIAN); +$fmt3 = new IntlDateFormatter('en_US@calendar=hebrew', + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + IntlDateFormatter::TRADITIONAL); +var_dump($fmt1->format(strtotime('2012-01-01 00:00:00 +0000'))); +var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000'))); +var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000'))); + +new IntlDateFormatter('en_US@calendar=hebrew', + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + -1); +?> +==DONE== +--EXPECTF-- +string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12" +string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12" +string(42) "Sunday, Tevet 6, 5772 5:12:00 AM GMT+05:12" + +Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN in %s on line %d +==DONE== diff --git a/ext/intl/tests/resourcebundle_null_mandatory_args.phpt b/ext/intl/tests/resourcebundle_null_mandatory_args.phpt new file mode 100644 index 000000000..8fde61bd2 --- /dev/null +++ b/ext/intl/tests/resourcebundle_null_mandatory_args.phpt @@ -0,0 +1,26 @@ +--TEST-- +IntlCalendar::setTime() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$r = new ResourceBundle('en_US', NULL); +$c = $r->get('calendar')->get('gregorian')->get('DateTimePatterns')->get(0); +var_dump($c); + +ini_set('intl.default_locale', 'pt_PT'); +$r = new ResourceBundle(NULL, NULL); +$c = $r->get('calendar')->get('gregorian')->get('DateTimePatterns')->get(0); +var_dump($c); +?> +==DONE== +--EXPECT-- +string(14) "h:mm:ss a zzzz" +string(12) "H:mm:ss zzzz" +==DONE== diff --git a/ext/intl/tests/resourcebundle_traversable.phpt b/ext/intl/tests/resourcebundle_traversable.phpt new file mode 100644 index 000000000..1e6af7b90 --- /dev/null +++ b/ext/intl/tests/resourcebundle_traversable.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #55610: ResourceBundle does not implement Traversable +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + include "resourcebundle.inc"; + + $r = new ResourceBundle( 'es', BUNDLE ); + + var_dump($r instanceof Traversable); + var_dump(iterator_to_array($r->get('testarray'))); +?> +--EXPECTF-- +bool(true) +array(3) { + [0]=> + string(8) "cadena 1" + [1]=> + string(8) "cadena 2" + [2]=> + string(8) "cadena 3" +} diff --git a/ext/libxml/tests/bug61367-read.phpt b/ext/libxml/tests/bug61367-read.phpt index 3deecfc50..94da3d848 100644 --- a/ext/libxml/tests/bug61367-read.phpt +++ b/ext/libxml/tests/bug61367-read.phpt @@ -4,11 +4,12 @@ Bug #61367: open_basedir bypass in libxml RSHUTDOWN: read test <?php if(!extension_loaded('dom')) echo 'skip'; ?> --INI-- open_basedir=. -; Suppress spurious "Trying to get property of non-object" notices error_reporting=E_ALL & ~E_NOTICE --FILE-- <?php - +/* + * Note: Using error_reporting=E_ALL & ~E_NOTICE to supress "Trying to get property of non-object" notices. + */ class StreamExploiter { public function stream_close ( ) { $doc = new DOMDocument; diff --git a/ext/libxml/tests/bug61367-write.phpt b/ext/libxml/tests/bug61367-write.phpt index aeed688ff..e18b07149 100644 --- a/ext/libxml/tests/bug61367-write.phpt +++ b/ext/libxml/tests/bug61367-write.phpt @@ -4,8 +4,6 @@ Bug #61367: open_basedir bypass in libxml RSHUTDOWN: write test <?php if(!extension_loaded('dom')) echo 'skip'; ?> --INI-- open_basedir=. -; Suppress spurious "Trying to get property of non-object" notices -error_reporting=E_ALL & ~E_NOTICE --FILE-- <?php diff --git a/ext/mysqli/tests/bug62046.phpt b/ext/mysqli/tests/bug62046.phpt new file mode 100644 index 000000000..31a7328b7 --- /dev/null +++ b/ext/mysqli/tests/bug62046.phpt @@ -0,0 +1,40 @@ +--TEST--
+Bug #62046 mysqli@mysqlnd can't iterate over stored sets after call to mysqli_stmt_reset()
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+ require_once("connect.inc");
+
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
+ if (FALSE === ($stmt = $link->prepare('SELECT 42'))) {
+ printf("[002] Prepare failed, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
+ if (FALSE === $stmt->execute()) {
+ printf("[003] Execute failed, [%d] %s\n", $stmt->errorno, $stmt->error);
+ }
+ if (FALSE === $stmt->store_result()) {
+ printf("[004] store_result failed, [%d] %s\n", $stmt->errorno, $stmt->error);
+ }
+ $one = NULL;
+ if (FALSE === $stmt->bind_result($one)) {
+ printf("[005] bind_result failed, [%d] %s\n", $stmt->errorno, $stmt->error);
+ }
+ if (FALSE === $stmt->reset()) {
+ printf("[006] bind_result failed, [%d] %s\n", $stmt->errorno, $stmt->error);
+ }
+ while ($stmt->fetch()) {
+ var_dump($one);
+ }
+ $stmt->close();
+ $link->close();
+ echo "done!";
+?>
+--EXPECT--
+int(42)
+done!
\ No newline at end of file diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c index 90e685654..1b48ba1d7 100644 --- a/ext/mysqlnd/mysqlnd_ps.c +++ b/ext/mysqlnd/mysqlnd_ps.c @@ -636,6 +636,8 @@ MYSQLND_METHOD(mysqlnd_stmt, execute)(MYSQLND_STMT * const s TSRMLS_DC) have it again. */ stmt->result->m.free_result_buffers(stmt->result TSRMLS_CC); + + stmt->state = MYSQLND_STMT_PREPARED; } else if (stmt->state < MYSQLND_STMT_PREPARED) { /* Only initted - error */ SET_CLIENT_ERROR(*conn->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, @@ -1221,8 +1223,6 @@ MYSQLND_METHOD(mysqlnd_stmt, reset)(MYSQLND_STMT * const s TSRMLS_DC) COPY_CLIENT_ERROR(*stmt->error_info, *conn->error_info); } *stmt->upsert_status = *conn->upsert_status; - - stmt->state = MYSQLND_STMT_PREPARED; } DBG_INF(ret == PASS? "PASS":"FAIL"); DBG_RETURN(ret); @@ -1261,8 +1261,6 @@ MYSQLND_METHOD(mysqlnd_stmt, flush)(MYSQLND_STMT * const s TSRMLS_DC) stmt->result->m.skip_result(stmt->result TSRMLS_CC); } } while (mysqlnd_stmt_more_results(s) && mysqlnd_stmt_next_result(s) == PASS); - - stmt->state = MYSQLND_STMT_PREPARED; } DBG_INF(ret == PASS? "PASS":"FAIL"); DBG_RETURN(ret); diff --git a/ext/phar/tar.c b/ext/phar/tar.c index b914db129..917734c99 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -38,7 +38,7 @@ static php_uint32 phar_tar_number(char *buf, int len) /* {{{ */ /* }}} */ /* adapted from format_octal() in libarchive - * + * * Copyright (c) 2003-2009 Tim Kientzle * All rights reserved. * @@ -161,7 +161,7 @@ static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp TSRM size_t save = php_stream_tell(fp), read; phar_entry_info *mentry; - metadata = (char *) emalloc(entry->uncompressed_filesize + 1); + metadata = (char *) safe_emalloc(1, entry->uncompressed_filesize, 1); read = php_stream_read(fp, metadata, entry->uncompressed_filesize); if (read != entry->uncompressed_filesize) { @@ -377,7 +377,7 @@ bail: } read = php_stream_read(fp, buf, sizeof(buf)); - + if (read != sizeof(buf)) { efree(entry.filename); if (error) { diff --git a/ext/phar/tests/fatal_error_webphar.phpt b/ext/phar/tests/fatal_error_webphar.phpt index 3153c344e..dd6e0961a 100644 --- a/ext/phar/tests/fatal_error_webphar.phpt +++ b/ext/phar/tests/fatal_error_webphar.phpt @@ -15,4 +15,4 @@ Content-type: text/html; charset=UTF-8 --EXPECTF-- string(9) "\Web\View" -Parse error: syntax error, unexpected %s, expecting %s in phar:///%sfatal_error_webphar.php/Web/View.php on line 380 +Parse error: syntax error, unexpected %s, expecting %s in phar://%r([A-Za-z]:)?%r/%sfatal_error_webphar.php/Web/View.php on line 380 diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 406da9382..1cf65cee1 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1457,49 +1457,6 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c } /* }}} */ -/* {{{ _reflection_param_get_default_param */ -static parameter_reference *_reflection_param_get_default_param(INTERNAL_FUNCTION_PARAMETERS) -{ - reflection_object *intern; - parameter_reference *param; - - GET_REFLECTION_OBJECT_PTR(param); - - if (param->fptr->type != ZEND_USER_FUNCTION) - { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot determine default value for internal functions"); - return NULL; - } - - if (param->offset < param->required) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional"); - return NULL; - } - - return param; -} -/* }}} */ - -/* {{{ _reflection_param_get_default_precv */ -static zend_op *_reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAMETERS, parameter_reference *param) -{ - zend_op *precv; - - param = param ? param : _reflection_param_get_default_param(INTERNAL_FUNCTION_PARAM_PASSTHRU); - if (!param) { - return NULL; - } - - precv = _get_recv_op((zend_op_array*)param->fptr, param->offset); - if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error"); - return NULL; - } - - return precv; -} -/* }}} */ - /* {{{ Preventing __clone from being called */ ZEND_METHOD(reflection, __clone) { @@ -2578,14 +2535,27 @@ ZEND_METHOD(reflection_parameter, isDefaultValueAvailable) Returns the default value of this parameter or throws an exception */ ZEND_METHOD(reflection_parameter, getDefaultValue) { - parameter_reference *param = _reflection_param_get_default_param(INTERNAL_FUNCTION_PARAM_PASSTHRU); - zend_op *precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param); + reflection_object *intern; + parameter_reference *param; + zend_op *precv; if (zend_parse_parameters_none() == FAILURE) { return; } + GET_REFLECTION_OBJECT_PTR(param); - if (!(param && precv)) { + if (param->fptr->type != ZEND_USER_FUNCTION) + { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot determine default value for internal functions"); + return; + } + if (param->offset < param->required) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional"); + return; + } + precv = _get_recv_op((zend_op_array*)param->fptr, param->offset); + if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error"); return; } @@ -2598,42 +2568,6 @@ ZEND_METHOD(reflection_parameter, getDefaultValue) } /* }}} */ -/* {{{ proto public bool ReflectionParameter::isDefaultValueConstant() - Returns whether the default value of this parameter is constant */ -ZEND_METHOD(reflection_parameter, isDefaultValueConstant) -{ - zend_op *precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL); - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - if (precv && (Z_TYPE_P(precv->op2.zv) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) { - RETURN_TRUE; - } - - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto public mixed ReflectionParameter::getDefaultValueConstantName() - Returns the default value's constant name if default value is constant or false */ -ZEND_METHOD(reflection_parameter, getDefaultValueConstantName) -{ - zend_op *precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL); - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - if (precv && (Z_TYPE_P(precv->op2.zv) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) { - RETURN_STRING(Z_STRVAL_P(precv->op2.zv), 1); - } - - RETURN_FALSE; -} -/* }}} */ - /* {{{ proto public static mixed ReflectionMethod::export(mixed class, string name [, bool return]) throws ReflectionException Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */ ZEND_METHOD(reflection_method, export) @@ -5969,8 +5903,6 @@ static const zend_function_entry reflection_parameter_functions[] = { ZEND_ME(reflection_parameter, isOptional, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, isDefaultValueAvailable, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getDefaultValue, arginfo_reflection__void, 0) - ZEND_ME(reflection_parameter, isDefaultValueConstant, arginfo_reflection__void, 0) - ZEND_ME(reflection_parameter, getDefaultValueConstantName, arginfo_reflection__void, 0) PHP_FE_END }; diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt deleted file mode 100644 index cdd00d262..000000000 --- a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt +++ /dev/null @@ -1,52 +0,0 @@ ---TEST-- -ReflectionParameter::isDefaultValueConstant() && getDefaultValueConstantName() ---FILE-- -<?php - -define("CONST_TEST_1", "const1"); - -function ReflectionParameterTest($test1=array(), $test2 = CONST_TEST_1) { - echo $test; -} -$reflect = new ReflectionFunction('ReflectionParameterTest'); -foreach($reflect->getParameters() as $param) { - if($param->getName() == 'test1') { - var_dump($param->isDefaultValueConstant()); - } - if($param->getName() == 'test2') { - var_dump($param->isDefaultValueConstant()); - } - if($param->isDefaultValueAvailable() && $param->isDefaultValueConstant()) { - var_dump($param->getDefaultValueConstantName()); - } -} - -class Foo2 { - const bar = 'Foo2::bar'; -} - -class Foo { - const bar = 'Foo::bar'; - - public function baz($param1 = self::bar, $param2=Foo2::bar, $param3=CONST_TEST_1) { - } -} - -$method = new ReflectionMethod('Foo', 'baz'); -$params = $method->getParameters(); - -foreach ($params as $param) { - if ($param->isDefaultValueConstant()) { - var_dump($param->getDefaultValueConstantName()); - } -} -?> -==DONE== ---EXPECT-- -bool(false) -bool(true) -string(12) "CONST_TEST_1" -string(9) "self::bar" -string(9) "Foo2::bar" -string(12) "CONST_TEST_1" -==DONE== diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt deleted file mode 100644 index 1ee9e9373..000000000 --- a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -ReflectionParameter::isDefaultValueConstant() && getDefaultValueConstantName() for namespace ---FILE-- -<?php - -namespace ReflectionTestNamespace { - CONST TEST_CONST_1 = "Test Const 1"; - - class TestClass { - const TEST_CONST_2 = "Test Const 2 in class"; - } -} - -namespace { - function ReflectionParameterTest($test=ReflectionTestNamespace\TestClass::TEST_CONST_2, $test2 = ReflectionTestNamespace\CONST_TEST_1) { - echo $test; - } - $reflect = new ReflectionFunction('ReflectionParameterTest'); - foreach($reflect->getParameters() as $param) { - if($param->isDefaultValueAvailable() && $param->isDefaultValueConstant()) { - echo $param->getDefaultValueConstantName() . "\n"; - } - } - echo "==DONE=="; -} -?> ---EXPECT-- -ReflectionTestNamespace\TestClass::TEST_CONST_2 -ReflectionTestNamespace\CONST_TEST_1 -==DONE== diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt deleted file mode 100644 index 984b06efe..000000000 --- a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -ReflectionParameter::getDefaultValueConstant() should raise exception on non optional parameter ---FILE-- -<?php - -define("CONST_TEST_1", "const1"); - -function ReflectionParameterTest($test, $test2 = CONST_TEST_1) { - echo $test; -} -$reflect = new ReflectionFunction('ReflectionParameterTest'); -foreach($reflect->getParameters() as $param) { - try { - echo $param->getDefaultValueConstantName() . "\n"; - } - catch(ReflectionException $e) { - echo $e->getMessage() . "\n"; - } -} -?> -==DONE== ---EXPECT-- -Parameter is not optional -CONST_TEST_1 -==DONE== diff --git a/ext/sockets/config.m4 b/ext/sockets/config.m4 index 3fb93aec7..4032621ce 100644 --- a/ext/sockets/config.m4 +++ b/ext/sockets/config.m4 @@ -27,6 +27,21 @@ if test "$PHP_SOCKETS" != "no"; then [AC_DEFINE(MISSING_MSGHDR_MSGFLAGS, 1, [ ])] ) AC_DEFINE([HAVE_SOCKETS], 1, [ ]) + + dnl Check for fied ss_family in sockaddr_storage (missing in AIX until 5.3) + AC_CACHE_CHECK([for field ss_family in struct sockaddr_storage], ac_cv_ss_family, + [ + AC_TRY_COMPILE([ +#include <sys/socket.h> +#include <sys/types.h> +#include <netdb.h> + ], [struct sockaddr_storage sa_store; sa_store.ss_family = AF_INET6;], + ac_cv_ss_family=yes, ac_cv_ss_family=no) + ]) + + if test "$ac_cv_ss_family" = yes; then + AC_DEFINE(HAVE_SA_SS_FAMILY,1,[Whether you have sockaddr_storage.ss_family]) + fi PHP_NEW_EXTENSION([sockets], [sockets.c multicast.c], [$ext_shared]) PHP_INSTALL_HEADERS([ext/sockets/], [php_sockets.h]) diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 46d9f8e1b..0d1714257 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -77,6 +77,9 @@ # define IS_INVALID_SOCKET(a) (a->bsd_socket < 0) # define set_errno(a) (errno = a) # include "php_sockets.h" +# if defined(_AIX) && !defined(HAVE_SA_SS_FAMILY) +# define ss_family __ss_family +# endif # if HAVE_IF_NAMETOINDEX # include <net/if.h> # endif diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index 42cb856e9..c6decd0ad 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -953,7 +953,7 @@ static int spl_heap_it_get_current_key(zend_object_iterator *iter, char **str_ke { spl_heap_it *iterator = (spl_heap_it *)iter; - *int_key = (ulong) iterator->object->heap->count; + *int_key = (ulong) iterator->object->heap->count - 1; return HASH_KEY_IS_LONG; } /* }}} */ diff --git a/ext/spl/tests/bug62073.phpt b/ext/spl/tests/bug62073.phpt new file mode 100644 index 000000000..3bd355317 --- /dev/null +++ b/ext/spl/tests/bug62073.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #62073 (different ways of iterating over an SplMaxHeap result in different keys) +--FILE-- +<?php +$heap = new SplMaxHeap(); +$heap->insert(42); +foreach ($heap as $key => $value) { + var_dump($key); + var_dump($value); + break; +} + +$heap = new SplMaxHeap(); +$heap->insert(42); +var_dump($heap->key()); +var_dump($heap->current()); +?> +--EXPECT-- +int(0) +int(42) +int(0) +int(42) diff --git a/ext/spl/tests/heap_005.phpt b/ext/spl/tests/heap_005.phpt index 73daaf454..1291cda77 100644 --- a/ext/spl/tests/heap_005.phpt +++ b/ext/spl/tests/heap_005.phpt @@ -18,104 +18,104 @@ foreach ($h as $k => $o) { ===DONE=== <?php exit(0); ?> --EXPECTF-- -100 => 1 -99 => 2 -98 => 3 -97 => 4 -96 => 5 -95 => 6 -94 => 7 -93 => 8 -92 => 9 -91 => 10 -90 => 11 -89 => 12 -88 => 13 -87 => 14 -86 => 15 -85 => 16 -84 => 17 -83 => 18 -82 => 19 -81 => 20 -80 => 21 -79 => 22 -78 => 23 -77 => 24 -76 => 25 -75 => 26 -74 => 27 -73 => 28 -72 => 29 -71 => 30 -70 => 31 -69 => 32 -68 => 33 -67 => 34 -66 => 35 -65 => 36 -64 => 37 -63 => 38 -62 => 39 -61 => 40 -60 => 41 -59 => 42 -58 => 43 -57 => 44 -56 => 45 -55 => 46 -54 => 47 -53 => 48 -52 => 49 -51 => 50 -50 => 51 -49 => 52 -48 => 53 -47 => 54 -46 => 55 -45 => 56 -44 => 57 -43 => 58 -42 => 59 -41 => 60 -40 => 61 -39 => 62 -38 => 63 -37 => 64 -36 => 65 -35 => 66 -34 => 67 -33 => 68 -32 => 69 -31 => 70 -30 => 71 -29 => 72 -28 => 73 -27 => 74 -26 => 75 -25 => 76 -24 => 77 -23 => 78 -22 => 79 -21 => 80 -20 => 81 -19 => 82 -18 => 83 -17 => 84 -16 => 85 -15 => 86 -14 => 87 -13 => 88 -12 => 89 -11 => 90 -10 => 91 -9 => 92 -8 => 93 -7 => 94 -6 => 95 -5 => 96 -4 => 97 -3 => 98 -2 => 99 -1 => 100 +99 => 1 +98 => 2 +97 => 3 +96 => 4 +95 => 5 +94 => 6 +93 => 7 +92 => 8 +91 => 9 +90 => 10 +89 => 11 +88 => 12 +87 => 13 +86 => 14 +85 => 15 +84 => 16 +83 => 17 +82 => 18 +81 => 19 +80 => 20 +79 => 21 +78 => 22 +77 => 23 +76 => 24 +75 => 25 +74 => 26 +73 => 27 +72 => 28 +71 => 29 +70 => 30 +69 => 31 +68 => 32 +67 => 33 +66 => 34 +65 => 35 +64 => 36 +63 => 37 +62 => 38 +61 => 39 +60 => 40 +59 => 41 +58 => 42 +57 => 43 +56 => 44 +55 => 45 +54 => 46 +53 => 47 +52 => 48 +51 => 49 +50 => 50 +49 => 51 +48 => 52 +47 => 53 +46 => 54 +45 => 55 +44 => 56 +43 => 57 +42 => 58 +41 => 59 +40 => 60 +39 => 61 +38 => 62 +37 => 63 +36 => 64 +35 => 65 +34 => 66 +33 => 67 +32 => 68 +31 => 69 +30 => 70 +29 => 71 +28 => 72 +27 => 73 +26 => 74 +25 => 75 +24 => 76 +23 => 77 +22 => 78 +21 => 79 +20 => 80 +19 => 81 +18 => 82 +17 => 83 +16 => 84 +15 => 85 +14 => 86 +13 => 87 +12 => 88 +11 => 89 +10 => 90 +9 => 91 +8 => 92 +7 => 93 +6 => 94 +5 => 95 +4 => 96 +3 => 97 +2 => 98 +1 => 99 +0 => 100 ===DONE=== diff --git a/ext/spl/tests/heap_006.phpt b/ext/spl/tests/heap_006.phpt index 4422727d0..3218bdfb1 100644 --- a/ext/spl/tests/heap_006.phpt +++ b/ext/spl/tests/heap_006.phpt @@ -18,104 +18,104 @@ foreach ($h as $k => $o) { ===DONE=== <?php exit(0); ?> --EXPECTF-- -100 => 100 -99 => 99 -98 => 98 -97 => 97 -96 => 96 -95 => 95 -94 => 94 -93 => 93 -92 => 92 -91 => 91 -90 => 90 -89 => 89 -88 => 88 -87 => 87 -86 => 86 -85 => 85 -84 => 84 -83 => 83 -82 => 82 -81 => 81 -80 => 80 -79 => 79 -78 => 78 -77 => 77 -76 => 76 -75 => 75 -74 => 74 -73 => 73 -72 => 72 -71 => 71 -70 => 70 -69 => 69 -68 => 68 -67 => 67 -66 => 66 -65 => 65 -64 => 64 -63 => 63 -62 => 62 -61 => 61 -60 => 60 -59 => 59 -58 => 58 -57 => 57 -56 => 56 -55 => 55 -54 => 54 -53 => 53 -52 => 52 -51 => 51 -50 => 50 -49 => 49 -48 => 48 -47 => 47 -46 => 46 -45 => 45 -44 => 44 -43 => 43 -42 => 42 -41 => 41 -40 => 40 -39 => 39 -38 => 38 -37 => 37 -36 => 36 -35 => 35 -34 => 34 -33 => 33 -32 => 32 -31 => 31 -30 => 30 -29 => 29 -28 => 28 -27 => 27 -26 => 26 -25 => 25 -24 => 24 -23 => 23 -22 => 22 -21 => 21 -20 => 20 -19 => 19 -18 => 18 -17 => 17 -16 => 16 -15 => 15 -14 => 14 -13 => 13 -12 => 12 -11 => 11 -10 => 10 -9 => 9 -8 => 8 -7 => 7 -6 => 6 -5 => 5 -4 => 4 -3 => 3 -2 => 2 -1 => 1 +99 => 100 +98 => 99 +97 => 98 +96 => 97 +95 => 96 +94 => 95 +93 => 94 +92 => 93 +91 => 92 +90 => 91 +89 => 90 +88 => 89 +87 => 88 +86 => 87 +85 => 86 +84 => 85 +83 => 84 +82 => 83 +81 => 82 +80 => 81 +79 => 80 +78 => 79 +77 => 78 +76 => 77 +75 => 76 +74 => 75 +73 => 74 +72 => 73 +71 => 72 +70 => 71 +69 => 70 +68 => 69 +67 => 68 +66 => 67 +65 => 66 +64 => 65 +63 => 64 +62 => 63 +61 => 62 +60 => 61 +59 => 60 +58 => 59 +57 => 58 +56 => 57 +55 => 56 +54 => 55 +53 => 54 +52 => 53 +51 => 52 +50 => 51 +49 => 50 +48 => 49 +47 => 48 +46 => 47 +45 => 46 +44 => 45 +43 => 44 +42 => 43 +41 => 42 +40 => 41 +39 => 40 +38 => 39 +37 => 38 +36 => 37 +35 => 36 +34 => 35 +33 => 34 +32 => 33 +31 => 32 +30 => 31 +29 => 30 +28 => 29 +27 => 28 +26 => 27 +25 => 26 +24 => 25 +23 => 24 +22 => 23 +21 => 22 +20 => 21 +19 => 20 +18 => 19 +17 => 18 +16 => 17 +15 => 16 +14 => 15 +13 => 14 +12 => 13 +11 => 12 +10 => 11 +9 => 10 +8 => 9 +7 => 8 +6 => 7 +5 => 6 +4 => 5 +3 => 4 +2 => 3 +1 => 2 +0 => 1 ===DONE=== diff --git a/ext/spl/tests/pqueue_001.phpt b/ext/spl/tests/pqueue_001.phpt index 9c299808f..de164e549 100644 --- a/ext/spl/tests/pqueue_001.phpt +++ b/ext/spl/tests/pqueue_001.phpt @@ -63,34 +63,34 @@ foreach ($pq3 as $k=>$v) { <?php exit(0); ?> --EXPECTF-- Exception: Can't extract from an empty heap -3=>b -2=>a -1=>c +2=>b +1=>a +0=>c EXTR_BOTH -3=>Array +2=>Array ( [data] => b [priority] => 2 ) -2=>Array +1=>Array ( [data] => a [priority] => 1 ) -1=>Array +0=>Array ( [data] => c [priority] => 0 ) EXTR_DATA -3=>b -2=>a -1=>c +2=>b +1=>a +0=>c EXTR_PRIORITY -3=>2 -2=>1 -1=>0 +2=>2 +1=>1 +0=>0 ===DONE=== diff --git a/ext/standard/crypt_freesec.c b/ext/standard/crypt_freesec.c index 49c397cca..0a5c3ba5f 100644 --- a/ext/standard/crypt_freesec.c +++ b/ext/standard/crypt_freesec.c @@ -629,7 +629,8 @@ _crypt_extended_r(const char *key, const char *setting, */ q = (u_char *) keybuf; while (q - (u_char *) keybuf < sizeof(keybuf)) { - if ((*q++ = *key << 1)) + *q++ = *key << 1; + if (*key) key++; } if (des_setkey((u_char *) keybuf, data)) diff --git a/ext/standard/math.c b/ext/standard/math.c index 65187f6fa..b3e8c6f08 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -1097,7 +1097,9 @@ PHPAPI char *_php_math_number_format(double d, int dec, char dec_point, char tho return _php_math_number_format_ex(d, dec, &dec_point, 1, &thousand_sep, 1); } -PHPAPI char *_php_math_number_format_ex(double d, int dec, char *dec_point, size_t dec_point_len, char *thousand_sep, size_t thousand_sep_len) +static char *_php_math_number_format_ex_len(double d, int dec, char *dec_point, + size_t dec_point_len, char *thousand_sep, size_t thousand_sep_len, + int *result_len) { char *tmpbuf = NULL, *resbuf; char *s, *t; /* source, target */ @@ -1205,8 +1207,19 @@ PHPAPI char *_php_math_number_format_ex(double d, int dec, char *dec_point, size efree(tmpbuf); + if (result_len) { + *result_len = reslen; + } + return resbuf; } + +PHPAPI char *_php_math_number_format_ex(double d, int dec, char *dec_point, + size_t dec_point_len, char *thousand_sep, size_t thousand_sep_len) +{ + return _php_math_number_format_ex_len(d, dec, dec_point, dec_point_len, + thousand_sep, thousand_sep_len, NULL); +} /* }}} */ /* {{{ proto string number_format(float number [, int num_decimal_places [, string dec_seperator, string thousands_seperator]]) @@ -1241,7 +1254,10 @@ PHP_FUNCTION(number_format) thousand_sep_len = 1; } - RETURN_STRING(_php_math_number_format_ex(num, dec, dec_point, dec_point_len, thousand_sep, thousand_sep_len), 0); + Z_TYPE_P(return_value) = IS_STRING; + Z_STRVAL_P(return_value) = _php_math_number_format_ex_len(num, dec, + dec_point, dec_point_len, thousand_sep, thousand_sep_len, + &Z_STRLEN_P(return_value)); break; default: WRONG_PARAM_COUNT; diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 4dd52ed28..5ff91994a 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -56,7 +56,7 @@ /* This symbol is defined in ext/standard/config.m4. * Essentially, it is set if you HAVE_FORK || PHP_WIN32 - * Otherplatforms may modify that configure check and add suitable #ifdefs + * Other platforms may modify that configure check and add suitable #ifdefs * around the alternate code. * */ #ifdef PHP_CAN_SUPPORT_PROC_OPEN diff --git a/ext/standard/tests/dir/dir_variation8-win32.phpt b/ext/standard/tests/dir/dir_variation8-win32.phpt index 2202fb048..a56c98b88 100644 --- a/ext/standard/tests/dir/dir_variation8-win32.phpt +++ b/ext/standard/tests/dir/dir_variation8-win32.phpt @@ -45,23 +45,23 @@ echo "Done"; *** Testing dir() : checking with wildcard characters *** -- wildcard = '*' -- -Warning: dir(%s/dir_var*,%s/dir_var*): No such file or directory in %s on line %d +Warning: dir(%s/dir_var*,%s/dir_var*): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d Warning: dir(%s/dir_var*): failed to open dir: %s in %s on line %d bool(false) -Warning: dir(%s/*,%s/*): No such file or directory in %s on line %d +Warning: dir(%s/*,%s/*): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d Warning: dir(%s/*): failed to open dir: %s in %s on line %d bool(false) -- wildcard = '?' -- -Warning: dir(%s/dir_variation81/sub_dir?,%s/dir_variation81/sub_dir?): No such file or directory in %s on line %d +Warning: dir(%s/dir_variation81/sub_dir?,%s/dir_variation81/sub_dir?): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d Warning: dir(%s/dir_variation81/sub_dir?): failed to open dir: %s in %s on line %d bool(false) -Warning: dir(%s/dir_variation81/sub?dir1,%s/dir_variation81/sub?dir1): No such file or directory in %s on line %d +Warning: dir(%s/dir_variation81/sub?dir1,%s/dir_variation81/sub?dir1): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d Warning: dir(%s/dir_variation81/sub?dir1): failed to open dir: %s in %s on line %d bool(false) diff --git a/ext/standard/tests/file/popen_pclose_basic-win32.phpt b/ext/standard/tests/file/popen_pclose_basic-win32.phpt index b5c72560d..6351d866f 100644 --- a/ext/standard/tests/file/popen_pclose_basic-win32.phpt +++ b/ext/standard/tests/file/popen_pclose_basic-win32.phpt @@ -39,7 +39,10 @@ $arr = array("ggg", "ddd", "aaa", "sss"); // // since we can't depend on PHP.ini being set a certain way, // have to put the absolute path here. -$file_handle = popen("/windows/system32/sort", "w"); + +$sysroot = exec('echo %SYSTEMROOT%'); + +$file_handle = popen("$sysroot/system32/sort", "w"); $newline = "\n"; foreach($arr as $str) { fwrite($file_handle, (binary)$str); diff --git a/ext/standard/tests/file/rename_variation13-win32.phpt b/ext/standard/tests/file/rename_variation13-win32.phpt Binary files differindex dc44b358f..a5030761a 100644 --- a/ext/standard/tests/file/rename_variation13-win32.phpt +++ b/ext/standard/tests/file/rename_variation13-win32.phpt diff --git a/ext/standard/tests/file/tempnam_variation7-win32.phpt b/ext/standard/tests/file/tempnam_variation7-win32.phpt index 1f0d97acf..0c8caca95 100644 --- a/ext/standard/tests/file/tempnam_variation7-win32.phpt +++ b/ext/standard/tests/file/tempnam_variation7-win32.phpt @@ -93,13 +93,13 @@ File created in => temp dir Warning: tempnam() expects parameter 1 to be a valid path, string given in %stempnam_variation7-win32.php on line %d -- File is not created -- -Warning: unlink(): Invalid argument in %s on line %d +Warning: unlink(): %r(Invalid argument|No such file or directory)%r in %s on line %d -- Iteration 7 -- Warning: tempnam() expects parameter 1 to be a valid path, array given in %s on line %d -- File is not created -- -Warning: unlink(): Invalid argument in %s on line %d +Warning: unlink(): %r(Invalid argument|No such file or directory)%r in %s on line %d -- Iteration 8 -- File name is => %s%et%s File permissions are => 100666 diff --git a/ext/standard/tests/mail/mail_skipif.inc b/ext/standard/tests/mail/mail_skipif.inc index 2f4fbf3d6..006594021 100644 --- a/ext/standard/tests/mail/mail_skipif.inc +++ b/ext/standard/tests/mail/mail_skipif.inc @@ -1,5 +1,15 @@ <?php extension_loaded('imap') or die('skip imap extension not available in this build'); + +if( substr(PHP_OS, 0, 3) == 'WIN' && extension_loaded('sockets')) { + // be sure mail server is accessible... on PHP 5.3.13 release build, using test-pack PHP-5.3-r1af8b3f, + // the code below didn't skip test even though there was no mail server + // test then failed (no mail server to test against) + $socket = socket_create(AF_INET, SOCK_RAW, 1); + socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 10, 'usec' => 10)); + // imap uses tcp port 143 + socket_connect($socket, "localhost", 143) or die ("skip can't socket to mail server"); +} // Change these to make tests run successfully $mailbox = '{localhost}'; diff --git a/ext/standard/tests/math/bug62112.phpt b/ext/standard/tests/math/bug62112.phpt Binary files differnew file mode 100644 index 000000000..01de35a9c --- /dev/null +++ b/ext/standard/tests/math/bug62112.phpt diff --git a/ext/standard/tests/strings/crypt_chars.phpt b/ext/standard/tests/strings/crypt_chars.phpt new file mode 100644 index 000000000..09cd86821 --- /dev/null +++ b/ext/standard/tests/strings/crypt_chars.phpt @@ -0,0 +1,19 @@ +--TEST-- +crypt() function - characters > 0x80 +--SKIPIF-- +<?php +if (!function_exists('crypt')) { + die("SKIP crypt() is not available"); +} +?> +--FILE-- +<?php +var_dump(crypt("À1234abcd", "99")); +var_dump(crypt("À9234abcd", "99")); +var_dump(crypt("À1234abcd", "_01234567")); +var_dump(crypt("À9234abcd", "_01234567")); +--EXPECT-- +string(13) "99PxawtsTfX56" +string(13) "99jcVcGxUZOWk" +string(20) "_01234567IBjxKliXXRQ" +string(20) "_012345678OSGpGQRVHA" diff --git a/ext/tidy/tests/004.phpt b/ext/tidy/tests/004.phpt index 7ca17c6d9..d13c37dcd 100644 --- a/ext/tidy/tests/004.phpt +++ b/ext/tidy/tests/004.phpt @@ -6,7 +6,7 @@ tidy_diagnose() <?php $a = tidy_parse_string('<HTML></HTML>'); var_dump(tidy_diagnose($a)); -echo tidy_get_error_buffer($a); +echo str_replace("\r", "", tidy_get_error_buffer($a)); $html = <<< HTML <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c index 84be01d70..0514b17ff 100644 --- a/ext/xmlwriter/php_xmlwriter.c +++ b/ext/xmlwriter/php_xmlwriter.c @@ -614,6 +614,7 @@ static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, i /* absolute file uris - libxml only supports localhost or empty host */ if (strncasecmp(source, "file:///", 8) == 0) { if (source[sizeof("file:///") - 1] == '\0') { + xmlFreeURI(uri); return NULL; } isFileUri = 1; @@ -624,6 +625,7 @@ static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, i #endif } else if (strncasecmp(source, "file://localhost/",17) == 0) { if (source[sizeof("file://localhost/") - 1] == '\0') { + xmlFreeURI(uri); return NULL; } diff --git a/main/php_config.h.in b/main/php_config.h.in index 326dc7bc7..cd96c1418 100644 --- a/main/php_config.h.in +++ b/main/php_config.h.in @@ -1498,6 +1498,9 @@ /* */ #undef HAVE_SAPDB +/* Whether you have sockaddr_storage.ss_family */ +#undef HAVE_SA_SS_FAMILY + /* Define to 1 if you have the `scandir' function. */ #undef HAVE_SCANDIR diff --git a/main/php_version.h b/main/php_version.h index 668b84334..6b49f4086 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -2,7 +2,7 @@ /* edit configure.in to change version number */ #define PHP_MAJOR_VERSION 5 #define PHP_MINOR_VERSION 4 -#define PHP_RELEASE_VERSION 4 -#define PHP_EXTRA_VERSION "-RC1" -#define PHP_VERSION "5.4.4-RC1" +#define PHP_RELEASE_VERSION 5 +#define PHP_EXTRA_VERSION "-dev" +#define PHP_VERSION "5.4.5-dev" #define PHP_VERSION_ID 50404 diff --git a/php.ini-development b/php.ini-development index 8e7073895..298cb06a7 100644 --- a/php.ini-development +++ b/php.ini-development @@ -751,7 +751,7 @@ enable_dl = Off ; will look for to know it is OK to continue execution. Setting this variable MAY ; cause security issues, KNOW WHAT YOU ARE DOING FIRST. ; http://php.net/cgi.redirect-status-env -;cgi.redirect_status_env = ; +;cgi.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 @@ -768,7 +768,7 @@ enable_dl = Off ; 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; +;fastcgi.impersonate = 1 ; Disable logging through FastCGI connection. PHP's default behavior is to enable ; this feature. diff --git a/php.ini-production b/php.ini-production index e8d1c748e..d4c1261fc 100644 --- a/php.ini-production +++ b/php.ini-production @@ -751,7 +751,7 @@ enable_dl = Off ; will look for to know it is OK to continue execution. Setting this variable MAY ; cause security issues, KNOW WHAT YOU ARE DOING FIRST. ; http://php.net/cgi.redirect-status-env -;cgi.redirect_status_env = ; +;cgi.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 @@ -768,7 +768,7 @@ enable_dl = Off ; 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; +;fastcgi.impersonate = 1 ; Disable logging through FastCGI connection. PHP's default behavior is to enable ; this feature. diff --git a/run-tests.php b/run-tests.php index 1fe0deb6a..2b37ec4f4 100755 --- a/run-tests.php +++ b/run-tests.php @@ -239,10 +239,7 @@ $ini_overwrites = array( 'magic_quotes_runtime=0', 'ignore_repeated_errors=0', 'precision=14', - 'unicode.runtime_encoding=ISO-8859-1', - 'unicode.script_encoding=UTF-8', - 'unicode.output_encoding=UTF-8', - 'unicode.from_error_mode=U_INVALID_SUBSTITUTE', + 'memory_limit=128M', ); function write_information($show_html) diff --git a/sapi/cgi/tests/apache_request_headers.phpt b/sapi/cgi/tests/apache_request_headers.phpt index 2c82d57b2..3dc3580c2 100644 --- a/sapi/cgi/tests/apache_request_headers.phpt +++ b/sapi/cgi/tests/apache_request_headers.phpt @@ -1,5 +1,7 @@ --TEST-- apache_request_headers() stack overflow. +--INI-- +default_charset="UTF-8" --SKIPIF-- <?php include "skipif.inc"; @@ -29,7 +31,7 @@ echo "Done\n"; ?> --EXPECTF-- X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 Array ( diff --git a/sapi/cli/tests/bug61546.phpt b/sapi/cli/tests/bug61546.phpt index 2cd690f65..071edb722 100644 --- a/sapi/cli/tests/bug61546.phpt +++ b/sapi/cli/tests/bug61546.phpt @@ -2,13 +2,22 @@ Bug #61546 (functions related to current script failed when chdir() in cli sapi) --FILE-- <?php +// reference doc for getmyinode() on php.net states that it returns an integer or FALSE on error +// on Windows, getmyinode() returns 0 which normally casts to FALSE +// however, the implementation of getmyinode() (in pageinfo.c) returns an explicit FALSE in the +// event that the internal page_inode structure is less than 0, otherwise it returns the long value +// of page_inode. therefore, an explicit 0 should be a passing value for this test. +// +// the ext/standard/tests/file/statpage.phpt test also tests getmyinode() returns an integer and will +// pass even if that integer is 0. on Windows, the getmyinode() call in statpage.phpt returns 0 and +// passes on Windows. $php = getenv("TEST_PHP_EXECUTABLE"); $test_code = <<<PHP <?php chdir('..'); var_dump(get_current_user() != ""); chdir('..'); -var_dump(getmyinode() != false); +var_dump(getmyinode() !== false); var_dump(getlastmod() != false); PHP; diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index 89628100b..ad46717ac 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -16,6 +16,7 @@ AC_DEFUN([AC_FPM_STDLIBS], AC_CHECK_HEADERS([errno.h fcntl.h stdio.h stdlib.h unistd.h sys/uio.h]) AC_CHECK_HEADERS([sys/select.h sys/socket.h sys/time.h]) AC_CHECK_HEADERS([arpa/inet.h netinet/in.h]) + AC_CHECK_HEADERS([sysexits.h]) ]) AC_DEFUN([AC_FPM_PRCTL], @@ -192,6 +193,8 @@ AC_DEFUN([AC_FPM_TRACE], have_ptrace=no have_broken_ptrace=yes AC_MSG_RESULT([no]) + ], [ + AC_MSG_RESULT([skipped (cross compiling)]) ]) fi @@ -264,6 +267,8 @@ AC_DEFUN([AC_FPM_TRACE], ], [ proc_mem_file="" AC_MSG_RESULT([no]) + ], [ + AC_MSG_RESULT([skipped (cross compiling)]) ]) fi diff --git a/sapi/fpm/fpm/fastcgi.c b/sapi/fpm/fpm/fastcgi.c index 212b6ff1d..e2e208aa7 100644 --- a/sapi/fpm/fpm/fastcgi.c +++ b/sapi/fpm/fpm/fastcgi.c @@ -399,7 +399,7 @@ static inline int fcgi_param_get_eff_len( unsigned char *p, unsigned char *end, { int ret = 1; int zero_found = 0; - *eff_len = 0; + *eff_len = 0; for (; p != end; ++p) { if (*p == '\0') { zero_found = 1; @@ -427,7 +427,7 @@ static int fcgi_get_params(fcgi_request *req, unsigned char *p, unsigned char *e char *tmp = buf; size_t buf_size = sizeof(buf); int name_len, val_len; - uint eff_name_len, eff_val_len; + uint eff_name_len; char *s; int ret = 1; size_t bytes_consumed; @@ -453,8 +453,12 @@ static int fcgi_get_params(fcgi_request *req, unsigned char *p, unsigned char *e ret = 0; break; } - if (!fcgi_param_get_eff_len(p, p+name_len, &eff_name_len) || - !fcgi_param_get_eff_len(p+name_len, p+name_len+val_len, &eff_val_len)) { + + /* + * get the effective length of the name in case it's not a valid string + * don't do this on the value because it can be binary data + */ + if (!fcgi_param_get_eff_len(p, p+name_len, &eff_name_len)){ /* Malicious request */ ret = 0; break; @@ -473,7 +477,7 @@ static int fcgi_get_params(fcgi_request *req, unsigned char *p, unsigned char *e } memcpy(tmp, p, eff_name_len); tmp[eff_name_len] = 0; - s = estrndup((char*)p + name_len, eff_val_len); + s = estrndup((char*)p + name_len, val_len); if (s == NULL) { ret = 0; break; diff --git a/sapi/fpm/fpm/fpm.c b/sapi/fpm/fpm/fpm.c index 96aabbfc4..dab415d12 100644 --- a/sapi/fpm/fpm/fpm.c +++ b/sapi/fpm/fpm/fpm.c @@ -37,10 +37,12 @@ struct fpm_globals_s fpm_globals = { .max_requests = 0, .is_child = 0, .test_successful = 0, - .heartbeat = 0 + .heartbeat = 0, + .run_as_root = 0, + .send_config_signal = 0, }; -int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf) /* {{{ */ +int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root) /* {{{ */ { fpm_globals.argc = argc; fpm_globals.argv = argv; @@ -49,6 +51,7 @@ int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int t } fpm_globals.prefix = prefix; fpm_globals.pid = pid; + fpm_globals.run_as_root = run_as_root; if (0 > fpm_php_init_main() || 0 > fpm_stdio_init_main() || @@ -64,7 +67,7 @@ int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int t 0 > fpm_event_init_main()) { if (fpm_globals.test_successful) { - exit(0); + exit(FPM_EXIT_OK); } else { zlog(ZLOG_ERROR, "FPM initialization failed"); return -1; diff --git a/sapi/fpm/fpm/fpm.h b/sapi/fpm/fpm/fpm.h index bfeac4d67..7a2903d07 100644 --- a/sapi/fpm/fpm/fpm.h +++ b/sapi/fpm/fpm/fpm.h @@ -7,8 +7,37 @@ #include <unistd.h> +#ifdef HAVE_SYSEXITS_H +#include <sysexits.h> +#endif + +#ifdef EX_OK +#define FPM_EXIT_OK EX_OK +#else +#define FPM_EXIT_OK 0 +#endif + +#ifdef EX_USAGE +#define FPM_EXIT_USAGE EX_USAGE +#else +#define FPM_EXIT_USAGE 64 +#endif + +#ifdef EX_SOFTWARE +#define FPM_EXIT_SOFTWARE EX_SOFTWARE +#else +#define FPM_EXIT_SOFTWARE 70 +#endif + +#ifdef EX_CONFIG +#define FPM_EXIT_CONFIG EX_CONFIG +#else +#define FPM_EXIT_CONFIG 78 +#endif + + int fpm_run(int *max_requests); -int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf); +int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root); struct fpm_globals_s { pid_t parent_pid; @@ -25,6 +54,8 @@ struct fpm_globals_s { int is_child; int test_successful; int heartbeat; + int run_as_root; + int send_config_signal; }; extern struct fpm_globals_s fpm_globals; diff --git a/sapi/fpm/fpm/fpm_children.c b/sapi/fpm/fpm/fpm_children.c index 35058b0ea..84a947433 100644 --- a/sapi/fpm/fpm/fpm_children.c +++ b/sapi/fpm/fpm/fpm_children.c @@ -156,7 +156,7 @@ static void fpm_child_init(struct fpm_worker_pool_s *wp) /* {{{ */ 0 > fpm_php_init_child(wp)) { zlog(ZLOG_ERROR, "[pool %s] child failed to initialize", wp->config->name); - exit(255); + exit(FPM_EXIT_SOFTWARE); } } /* }}} */ @@ -198,7 +198,7 @@ void fpm_children_bury() /* {{{ */ restart_child = 0; } - if (WEXITSTATUS(status) != 0) { + if (WEXITSTATUS(status) != FPM_EXIT_OK) { severity = ZLOG_WARNING; } diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index 304076d35..1f3258f35 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -70,6 +70,7 @@ struct fpm_global_config_s fpm_global_config = { .syslog_facility = -1, #endif .process_max = 0, + .process_priority = 64, /* 64 means unset */ }; static struct fpm_worker_pool_s *current_wp = NULL; static int ini_recursion = 0; @@ -92,6 +93,7 @@ static struct ini_value_parser_s ini_fpm_global_options[] = { { "emergency_restart_interval", &fpm_conf_set_time, GO(emergency_restart_interval) }, { "process_control_timeout", &fpm_conf_set_time, GO(process_control_timeout) }, { "process.max", &fpm_conf_set_integer, GO(process_max) }, + { "process.priority", &fpm_conf_set_integer, GO(process_priority) }, { "daemonize", &fpm_conf_set_boolean, GO(daemonize) }, { "rlimit_files", &fpm_conf_set_integer, GO(rlimit_files) }, { "rlimit_core", &fpm_conf_set_rlimit_core, GO(rlimit_core) }, @@ -112,6 +114,7 @@ static struct ini_value_parser_s ini_fpm_pool_options[] = { { "listen.group", &fpm_conf_set_string, WPO(listen_group) }, { "listen.mode", &fpm_conf_set_string, WPO(listen_mode) }, { "listen.allowed_clients", &fpm_conf_set_string, WPO(listen_allowed_clients) }, + { "process.priority", &fpm_conf_set_integer, WPO(process_priority) }, { "pm", &fpm_conf_set_pm, WPO(pm) }, { "pm.max_children", &fpm_conf_set_integer, WPO(pm_max_children) }, { "pm.start_servers", &fpm_conf_set_integer, WPO(pm_start_servers) }, @@ -577,6 +580,7 @@ static void *fpm_worker_pool_config_alloc() /* {{{ */ memset(wp->config, 0, sizeof(struct fpm_worker_pool_config_s)); wp->config->listen_backlog = FPM_BACKLOG_DEFAULT; wp->config->pm_process_idle_timeout = 10; /* 10s by default */ + wp->config->process_priority = 64; /* 64 means unset */ if (!fpm_worker_all_pools) { fpm_worker_all_pools = wp; @@ -704,7 +708,7 @@ static int fpm_evaluate_full_path(char **path, struct fpm_worker_pool_s *wp, cha static int fpm_conf_process_all_pools() /* {{{ */ { - struct fpm_worker_pool_s *wp; + struct fpm_worker_pool_s *wp, *wp2; if (!fpm_worker_all_pools) { zlog(ZLOG_ERROR, "No pool defined. at least one pool section must be specified in config file"); @@ -723,8 +727,8 @@ static int fpm_conf_process_all_pools() /* {{{ */ } } - /* user */ - if (!wp->config->user) { + /* alert if user is not set only if we are not root*/ + if (!wp->config->user && !geteuid()) { zlog(ZLOG_ALERT, "[pool %s] user has not been defined", wp->config->name); return -1; } @@ -741,6 +745,11 @@ static int fpm_conf_process_all_pools() /* {{{ */ return -1; } + if (wp->config->process_priority != 64 && (wp->config->process_priority < -19 || wp->config->process_priority > 20)) { + zlog(ZLOG_ERROR, "[pool %s] process.priority must be included into [-19,20]", wp->config->name); + return -1; + } + /* pm */ if (wp->config->pm != PM_STYLE_STATIC && wp->config->pm != PM_STYLE_DYNAMIC && wp->config->pm != PM_STYLE_ONDEMAND) { zlog(ZLOG_ALERT, "[pool %s] the process manager is missing (static, dynamic or ondemand)", wp->config->name); @@ -1044,6 +1053,20 @@ static int fpm_conf_process_all_pools() /* {{{ */ } } } + + /* ensure 2 pools do not use the same listening address */ + for (wp = fpm_worker_all_pools; wp; wp = wp->next) { + for (wp2 = fpm_worker_all_pools; wp2; wp2 = wp2->next) { + if (wp == wp2) { + continue; + } + + if (wp->config->listen_address && *wp->config->listen_address && wp2->config->listen_address && *wp2->config->listen_address && !strcmp(wp->config->listen_address, wp2->config->listen_address)) { + zlog(ZLOG_ERROR, "[pool %s] unable to set listen address as it's already used in another pool '%s'", wp2->config->name, wp->config->name); + return -1; + } + } + } return 0; } /* }}} */ @@ -1103,6 +1126,11 @@ static int fpm_conf_post_process(TSRMLS_D) /* {{{ */ return -1; } + if (fpm_global_config.process_priority != 64 && (fpm_global_config.process_priority < -19 || fpm_global_config.process_priority > 20)) { + zlog(ZLOG_ERROR, "process.priority must be included into [-19,20]"); + return -1; + } + if (!fpm_global_config.error_log) { fpm_global_config.error_log = strdup("log/php-fpm.log"); } @@ -1485,6 +1513,11 @@ static void fpm_conf_dump() /* {{{ */ zlog(ZLOG_NOTICE, "\temergency_restart_threshold = %d", fpm_global_config.emergency_restart_threshold); zlog(ZLOG_NOTICE, "\tprocess_control_timeout = %ds", fpm_global_config.process_control_timeout); zlog(ZLOG_NOTICE, "\tprocess.max = %d", fpm_global_config.process_max); + if (fpm_global_config.process_priority == 64) { + zlog(ZLOG_NOTICE, "\tprocess.priority = undefined"); + } else { + zlog(ZLOG_NOTICE, "\tprocess.priority = %d", fpm_global_config.process_priority); + } zlog(ZLOG_NOTICE, "\tdaemonize = %s", BOOL2STR(fpm_global_config.daemonize)); zlog(ZLOG_NOTICE, "\trlimit_files = %d", fpm_global_config.rlimit_files); zlog(ZLOG_NOTICE, "\trlimit_core = %d", fpm_global_config.rlimit_core); @@ -1504,6 +1537,11 @@ static void fpm_conf_dump() /* {{{ */ zlog(ZLOG_NOTICE, "\tlisten.group = %s", STR2STR(wp->config->listen_group)); zlog(ZLOG_NOTICE, "\tlisten.mode = %s", STR2STR(wp->config->listen_mode)); zlog(ZLOG_NOTICE, "\tlisten.allowed_clients = %s", STR2STR(wp->config->listen_allowed_clients)); + if (wp->config->process_priority == 64) { + zlog(ZLOG_NOTICE, "\tprocess.priority = undefined"); + } else { + zlog(ZLOG_NOTICE, "\tprocess.priority = %d", wp->config->process_priority); + } zlog(ZLOG_NOTICE, "\tpm = %s", PM2STR(wp->config->pm)); zlog(ZLOG_NOTICE, "\tpm.max_children = %d", wp->config->pm_max_children); zlog(ZLOG_NOTICE, "\tpm.start_servers = %d", wp->config->pm_start_servers); diff --git a/sapi/fpm/fpm/fpm_conf.h b/sapi/fpm/fpm/fpm_conf.h index 9fbd5064c..f780f0389 100644 --- a/sapi/fpm/fpm/fpm_conf.h +++ b/sapi/fpm/fpm/fpm_conf.h @@ -35,6 +35,7 @@ struct fpm_global_config_s { int emergency_restart_interval; int process_control_timeout; int process_max; + int process_priority; int daemonize; int rlimit_files; int rlimit_core; @@ -57,6 +58,7 @@ struct fpm_worker_pool_config_s { char *listen_group; char *listen_mode; char *listen_allowed_clients; + int process_priority; int pm; int pm_max_children; int pm_start_servers; diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 14dccbd14..83b461b79 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -154,6 +154,7 @@ static const opt_struct OPTIONS[] = { {'t', 0, "test"}, {'p', 1, "prefix"}, {'g', 1, "pid"}, + {'R', 0, "allow-to-run-as-root"}, {'-', 0, NULL} /* end of args */ }; @@ -646,12 +647,38 @@ static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC) } } -static void sapi_cgi_log_message(char *message TSRMLS_DC) +/* {{{ sapi_cgi_log_fastcgi + * + * Ignore level, we want to send all messages through fastcgi + */ +void sapi_cgi_log_fastcgi(int level, char *message, size_t len) { - if (CGIG(fcgi_logging)) { - zlog(ZLOG_NOTICE, "PHP message: %s", message); + TSRMLS_FETCH(); + + fcgi_request *request = (fcgi_request*) SG(server_context); + + /* ensure we want: + * - to log (fastcgi.logging in php.ini) + * - we are currently dealing with a request + * - the message is not empty + */ + if (CGIG(fcgi_logging) && request && message && len > 0) { + char *buf = malloc(len + 2); + memcpy(buf, message, len); + memcpy(buf + len, "\n", sizeof("\n")); + fcgi_write(request, FCGI_STDERR, buf, len+1); + free(buf); } } +/* }}} */ + +/* {{{ sapi_cgi_log_message + */ +static void sapi_cgi_log_message(char *message) +{ + zlog(ZLOG_NOTICE, "PHP message: %s", message); +} +/* }}} */ /* {{{ php_cgi_ini_activate_user_config */ @@ -900,7 +927,9 @@ static void php_cgi_usage(char *argv0) " Specify the PID file location.\n" " -y, --fpm-config <file>\n" " Specify alternative path to FastCGI process manager config file.\n" - " -t, --test Test FPM configuration and exit\n", + " -t, --test Test FPM configuration and exit\n" + " -R, --allow-to-run-as-root\n" + " Allow pool to run as root (disabled by default)\n", prog, PHP_PREFIX); } /* }}} */ @@ -1499,7 +1528,7 @@ static zend_module_entry cgi_module_entry = { */ int main(int argc, char *argv[]) { - int exit_status = SUCCESS; + int exit_status = FPM_EXIT_OK; int cgi = 0, c, use_extended_info = 0; zend_file_handle file_handle; @@ -1522,6 +1551,7 @@ int main(int argc, char *argv[]) char *fpm_pid = NULL; int test_conf = 0; int php_information = 0; + int php_allow_to_run_as_root = 0; #ifdef HAVE_SIGNAL_H #if defined(SIGPIPE) && defined(SIG_IGN) @@ -1629,13 +1659,17 @@ int main(int argc, char *argv[]) php_output_end_all(TSRMLS_C); php_output_deactivate(TSRMLS_C); fcgi_shutdown(); - exit_status = 0; + exit_status = FPM_EXIT_OK; goto out; case 'i': /* php info & quit */ php_information = 1; break; + case 'R': /* allow to run as root */ + php_allow_to_run_as_root = 1; + break; + default: case 'h': case '?': @@ -1646,7 +1680,7 @@ int main(int argc, char *argv[]) php_output_end_all(TSRMLS_C); php_output_deactivate(TSRMLS_C); fcgi_shutdown(); - exit_status = 0; + exit_status = (c == 'h') ? FPM_EXIT_OK : FPM_EXIT_USAGE; goto out; case 'v': /* show php version & quit */ @@ -1654,7 +1688,7 @@ int main(int argc, char *argv[]) if (php_request_startup(TSRMLS_C) == FAILURE) { SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); - return FAILURE; + return FPM_EXIT_SOFTWARE; } SG(headers_sent) = 1; SG(request_info).no_headers = 1; @@ -1666,7 +1700,7 @@ int main(int argc, char *argv[]) #endif php_request_shutdown((void *) 0); fcgi_shutdown(); - exit_status = 0; + exit_status = FPM_EXIT_OK; goto out; } } @@ -1677,14 +1711,14 @@ int main(int argc, char *argv[]) if (php_request_startup(TSRMLS_C) == FAILURE) { SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); - return FAILURE; + return FPM_EXIT_SOFTWARE; } SG(headers_sent) = 1; SG(request_info).no_headers = 1; php_print_info(0xFFFFFFFF TSRMLS_CC); php_request_shutdown((void *) 0); fcgi_shutdown(); - exit_status = 0; + exit_status = FPM_EXIT_OK; goto out; } @@ -1697,7 +1731,7 @@ int main(int argc, char *argv[]) php_output_end_all(TSRMLS_C); php_output_deactivate(TSRMLS_C); fcgi_shutdown(); - exit_status = 0; + exit_status = FPM_EXIT_USAGE; goto out; } @@ -1716,7 +1750,7 @@ int main(int argc, char *argv[]) #ifdef ZTS tsrm_shutdown(); #endif - return FAILURE; + return FPM_EXIT_SOFTWARE; } if (use_extended_info) { @@ -1759,19 +1793,31 @@ consult the installation file that came with this distribution, or visit \n\ */ tsrm_shutdown(); #endif - return FAILURE; + return FPM_EXIT_SOFTWARE; } } - if (0 > fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), fpm_prefix, fpm_pid, test_conf)) { - return FAILURE; + if (0 > fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), fpm_prefix, fpm_pid, test_conf, php_allow_to_run_as_root)) { + + if (fpm_globals.send_config_signal) { + zlog(ZLOG_DEBUG, "Sending SIGUSR2 (error) to parent %d", getppid()); + kill(getppid(), SIGUSR2); + } + return FPM_EXIT_CONFIG; } + if (fpm_globals.send_config_signal) { + zlog(ZLOG_DEBUG, "Sending SIGUSR1 (OK) to parent %d", getppid()); + kill(getppid(), SIGUSR1); + } fpm_is_running = 1; fcgi_fd = fpm_run(&max_requests); parent = 0; + /* onced forked tell zlog to also send messages through sapi_cgi_log_fastcgi() */ + zlog_set_external_logger(sapi_cgi_log_fastcgi); + /* make php call us to get _ENV vars */ php_php_import_environment_variables = php_import_environment_variables; php_import_environment_variables = cgi_php_import_environment_variables; @@ -1795,7 +1841,7 @@ consult the installation file that came with this distribution, or visit \n\ fcgi_finish_request(&request, 1); SG(server_context) = NULL; php_module_shutdown(TSRMLS_C); - return FAILURE; + return FPM_EXIT_SOFTWARE; } /* check if request_method has been sent. @@ -1883,17 +1929,9 @@ fastcgi_request_done: php_request_shutdown((void *) 0); - if (exit_status == 0) { - exit_status = EG(exit_status); - } - requests++; if (max_requests && (requests == max_requests)) { fcgi_finish_request(&request, 1); - if (max_requests != 1) { - /* no need to return exit_status of the last request */ - exit_status = 0; - } break; } /* end of fastcgi loop */ @@ -1907,7 +1945,7 @@ fastcgi_request_done: free(cgi_sapi_module.ini_entries); } } zend_catch { - exit_status = 255; + exit_status = FPM_EXIT_SOFTWARE; } zend_end_try(); out: diff --git a/sapi/fpm/fpm/fpm_process_ctl.c b/sapi/fpm/fpm/fpm_process_ctl.c index e698eb0ca..7840d17f8 100644 --- a/sapi/fpm/fpm/fpm_process_ctl.c +++ b/sapi/fpm/fpm/fpm_process_ctl.c @@ -71,7 +71,7 @@ static void fpm_pctl_exit() /* {{{ */ fpm_conf_unlink_pid(); fpm_cleanups_run(FPM_CLEANUP_PARENT_EXIT_MAIN); - exit(0); + exit(FPM_EXIT_OK); } /* }}} */ @@ -100,7 +100,7 @@ static void fpm_pctl_exec() /* {{{ */ fpm_cleanups_run(FPM_CLEANUP_PARENT_EXEC); execvp(saved_argv[0], saved_argv); zlog(ZLOG_SYSERROR, "failed to reload: execvp() failed"); - exit(1); + exit(FPM_EXIT_SOFTWARE); } /* }}} */ diff --git a/sapi/fpm/fpm/fpm_signals.c b/sapi/fpm/fpm/fpm_signals.c index 8993a860a..656269f1a 100644 --- a/sapi/fpm/fpm/fpm_signals.c +++ b/sapi/fpm/fpm/fpm_signals.c @@ -249,3 +249,15 @@ int fpm_signals_get_fd() /* {{{ */ } /* }}} */ +void fpm_signals_sighandler_exit_ok(pid_t pid) /* {{{ */ +{ + exit(FPM_EXIT_OK); +} +/* }}} */ + +void fpm_signals_sighandler_exit_config(pid_t pid) /* {{{ */ +{ + exit(FPM_EXIT_CONFIG); +} +/* }}} */ + diff --git a/sapi/fpm/fpm/fpm_signals.h b/sapi/fpm/fpm/fpm_signals.h index eb80faecf..13484cbac 100644 --- a/sapi/fpm/fpm/fpm_signals.h +++ b/sapi/fpm/fpm/fpm_signals.h @@ -11,6 +11,9 @@ int fpm_signals_init_main(); int fpm_signals_init_child(); int fpm_signals_get_fd(); +void fpm_signals_sighandler_exit_ok(pid_t pid); +void fpm_signals_sighandler_exit_config(pid_t pid); + extern const char *fpm_signal_names[NSIG + 1]; #endif diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c index cb4897e9b..d24dcccc9 100644 --- a/sapi/fpm/fpm/fpm_sockets.c +++ b/sapi/fpm/fpm/fpm_sockets.c @@ -179,6 +179,10 @@ static int fpm_sockets_new_listening_socket(struct fpm_worker_pool_s *wp, struct setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &flags, sizeof(flags)); if (wp->listen_address_domain == FPM_AF_UNIX) { + if (fpm_socket_unix_test_connect((struct sockaddr_un *)sa, socklen) == 0) { + zlog(ZLOG_ERROR, "An another FPM instance seems to already listen on %s", ((struct sockaddr_un *) sa)->sun_path); + return -1; + } unlink( ((struct sockaddr_un *) sa)->sun_path); saved_umask = umask(0777 ^ wp->socket_mode); } @@ -450,3 +454,24 @@ int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq) } #endif + +int fpm_socket_unix_test_connect(struct sockaddr_un *sun, size_t socklen) /* {{{ */ +{ + int fd; + + if (!sun || sun->sun_family != AF_UNIX) { + return -1; + } + + if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { + return -1; + } + + if (connect(fd, (struct sockaddr *)sun, socklen) == -1) { + return -1; + } + + close(fd); + return 0; +} +/* }}} */ diff --git a/sapi/fpm/fpm/fpm_sockets.h b/sapi/fpm/fpm/fpm_sockets.h index 447fbff4b..5b9c698c2 100644 --- a/sapi/fpm/fpm/fpm_sockets.h +++ b/sapi/fpm/fpm/fpm_sockets.h @@ -5,6 +5,8 @@ #ifndef FPM_MISC_H #define FPM_MISC_H 1 +#include <sys/types.h> +#include <sys/socket.h> #include <unistd.h> #include <fcntl.h> @@ -22,6 +24,7 @@ enum fpm_address_domain fpm_sockets_domain_from_address(char *addr); int fpm_sockets_init_main(); int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq); +int fpm_socket_unix_test_connect(struct sockaddr_un *sun, size_t socklen); static inline int fd_set_blocked(int fd, int blocked) /* {{{ */ diff --git a/sapi/fpm/fpm/fpm_unix.c b/sapi/fpm/fpm/fpm_unix.c index 17d0b8125..5c5e37c3a 100644 --- a/sapi/fpm/fpm/fpm_unix.c +++ b/sapi/fpm/fpm/fpm_unix.c @@ -23,6 +23,7 @@ #include "fpm_clock.h" #include "fpm_stdio.h" #include "fpm_unix.h" +#include "fpm_signals.h" #include "zlog.h" size_t fpm_pagesize; @@ -112,12 +113,12 @@ static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */ } } -#ifndef I_REALLY_WANT_ROOT_PHP - if (wp->set_uid == 0 || wp->set_gid == 0) { - zlog(ZLOG_ERROR, "[pool %s] please specify user and group other than root", wp->config->name); - return -1; + if (!fpm_globals.run_as_root) { + if (wp->set_uid == 0 || wp->set_gid == 0) { + zlog(ZLOG_ERROR, "[pool %s] please specify user and group other than root", wp->config->name); + return -1; + } } -#endif } else { /* not root */ if (wp->config->user && *wp->config->user) { zlog(ZLOG_WARNING, "[pool %s] 'user' directive is ignored when FPM is not running as root", wp->config->name); @@ -128,6 +129,9 @@ static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */ if (wp->config->chroot && *wp->config->chroot) { zlog(ZLOG_WARNING, "[pool %s] 'chroot' directive is ignored when FPM is not running as root", wp->config->name); } + if (wp->config->process_priority != 64) { + zlog(ZLOG_WARNING, "[pool %s] 'process.priority' directive is ignored when FPM is not running as root", wp->config->name); + } /* set up HOME and USER anyway */ pwd = getpwuid(getuid()); @@ -183,6 +187,14 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */ } if (is_root) { + + if (wp->config->process_priority != 64) { + if (setpriority(PRIO_PROCESS, 0, wp->config->process_priority) < 0) { + zlog(ZLOG_SYSERROR, "[pool %s] Unable to set priority for this new process", wp->config->name); + return -1; + } + } + if (wp->set_gid) { if (0 > setgid(wp->set_gid)) { zlog(ZLOG_SYSERROR, "[pool %s] failed to setgid(%d)", wp->config->name, wp->set_gid); @@ -217,6 +229,7 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */ int fpm_unix_init_main() /* {{{ */ { struct fpm_worker_pool_s *wp; + int is_root = !geteuid(); if (fpm_global_config.rlimit_files) { struct rlimit r; @@ -242,23 +255,92 @@ int fpm_unix_init_main() /* {{{ */ fpm_pagesize = getpagesize(); if (fpm_global_config.daemonize) { - switch (fork()) { - case -1 : + /* + * If daemonize, the calling process will die soon + * and the master process continues to initialize itself. + * + * The parent process has then to wait for the master + * process to initialize to return a consistent exit + * value. For this pupose, the master process will + * send USR1 if everything went well and USR2 + * otherwise. + */ + + struct sigaction act; + struct sigaction oldact_usr1; + struct sigaction oldact_usr2; + struct timeval tv; + + /* + * set sigaction for USR1 before fork + * save old sigaction to restore it after + * fork in the child process (the master process) + */ + memset(&act, 0, sizeof(act)); + memset(&act, 0, sizeof(oldact_usr1)); + act.sa_handler = fpm_signals_sighandler_exit_ok; + sigfillset(&act.sa_mask); + sigaction(SIGUSR1, &act, &oldact_usr1); + + /* + * set sigaction for USR2 before fork + * save old sigaction to restore it after + * fork in the child process (the master process) + */ + memset(&act, 0, sizeof(act)); + memset(&act, 0, sizeof(oldact_usr2)); + act.sa_handler = fpm_signals_sighandler_exit_config; + sigfillset(&act.sa_mask); + sigaction(SIGUSR2, &act, &oldact_usr2); + + /* then fork */ + pid_t pid = fork(); + switch (pid) { + + case -1 : /* error */ zlog(ZLOG_SYSERROR, "failed to daemonize"); return -1; - case 0 : + + case 0 : /* children */ + /* restore USR1 and USR2 sigaction */ + sigaction(SIGUSR1, &oldact_usr1, NULL); + sigaction(SIGUSR2, &oldact_usr2, NULL); + fpm_globals.send_config_signal = 1; break; - default : + + default : /* parent */ fpm_cleanups_run(FPM_CLEANUP_PARENT_EXIT); - exit(0); + + /* + * wait for 10s before exiting with error + * the child is supposed to send USR1 or USR2 to tell the parent + * how it goes for it + */ + tv.tv_sec = 10; + tv.tv_usec = 0; + zlog(ZLOG_DEBUG, "The calling process is waiting for the master process to ping"); + select(0, NULL, NULL, NULL, &tv); + exit(FPM_EXIT_SOFTWARE); } } + /* continue as a child */ setsid(); if (0 > fpm_clock_init()) { return -1; } + if (fpm_global_config.process_priority != 64) { + if (is_root) { + if (setpriority(PRIO_PROCESS, 0, fpm_global_config.process_priority) < 0) { + zlog(ZLOG_SYSERROR, "Unable to set priority for the master process"); + return -1; + } + } else { + zlog(ZLOG_WARNING, "'process.priority' directive is ignored when FPM is not running as root"); + } + } + fpm_globals.parent_pid = getpid(); for (wp = fpm_worker_all_pools; wp; wp = wp->next) { if (0 > fpm_unix_conf_wp(wp)) { diff --git a/sapi/fpm/fpm/zlog.c b/sapi/fpm/fpm/zlog.c index b127ec16f..80db9d837 100644 --- a/sapi/fpm/fpm/zlog.c +++ b/sapi/fpm/fpm/zlog.c @@ -22,6 +22,7 @@ static int zlog_fd = -1; static int zlog_level = ZLOG_NOTICE; static int launched = 0; +static void (*external_logger)(int, char *, size_t) = NULL; static const char *level_names[] = { [ZLOG_DEBUG] = "DEBUG", @@ -41,6 +42,12 @@ const int syslog_priorities[] = { }; #endif +void zlog_set_external_logger(void (*logger)(int, char *, size_t)) /* {{{ */ +{ + external_logger = logger; +} +/* }}} */ + const char *zlog_get_level_name(int log_level) /* {{{ */ { if (log_level < 0) { @@ -101,6 +108,19 @@ void zlog_ex(const char *function, int line, int flags, const char *fmt, ...) /* int truncated = 0; int saved_errno; + if (external_logger) { + va_start(args, fmt); + len = vsnprintf(buf, buf_size, fmt, args); + va_end(args); + if (len >= buf_size) { + memcpy(buf + buf_size - sizeof("..."), "...", sizeof("...") - 1); + len = buf_size - 1; + } + external_logger(flags & ZLOG_LEVEL_MASK, buf, len); + len = 0; + memset(buf, '\0', buf_size); + } + if ((flags & ZLOG_LEVEL_MASK) < zlog_level) { return; } diff --git a/sapi/fpm/fpm/zlog.h b/sapi/fpm/fpm/zlog.h index e6a5c019a..1945922da 100644 --- a/sapi/fpm/fpm/zlog.h +++ b/sapi/fpm/fpm/zlog.h @@ -9,6 +9,7 @@ struct timeval; +void zlog_set_external_logger(void (*logger)(int, char *, size_t)); int zlog_set_fd(int new_fd); int zlog_set_level(int new_value); const char *zlog_get_level_name(int log_level); diff --git a/sapi/fpm/php-fpm.conf.in b/sapi/fpm/php-fpm.conf.in index 2dad9d7f5..a63dec709 100644 --- a/sapi/fpm/php-fpm.conf.in +++ b/sapi/fpm/php-fpm.conf.in @@ -76,6 +76,14 @@ ; Default Value: 0 ; process.max = 128 +; Specify the nice(2) priority to apply to the master process (only if set) +; The value can vary from -19 (highest priority) to 20 (lower priority) +; Note: - It will only work if the FPM master process is launched as root +; - The pool process will inherit the master process priority +; unless it specified otherwise +; Default Value: no set +; process.priority = -19 + ; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging. ; Default Value: yes ;daemonize = yes @@ -163,6 +171,14 @@ listen = 127.0.0.1:9000 ; Default Value: any ;listen.allowed_clients = 127.0.0.1 +; Specify the nice(2) priority to apply to the pool processes (only if set) +; The value can vary from -19 (highest priority) to 20 (lower priority) +; Note: - It will only work if the FPM master process is launched as root +; - The pool processes will inherit the master process priority +; unless it specified otherwise +; Default Value: no set +; priority = -19 + ; Choose how the process manager will control the number of child processes. ; Possible Values: ; static - a fixed number (pm.max_children) of child processes; diff --git a/win32/registry.c b/win32/registry.c index 35b411f4c..45e842b45 100644 --- a/win32/registry.c +++ b/win32/registry.c @@ -77,11 +77,16 @@ static int LoadDirectory(HashTable *directories, HKEY key, char *path, int path_ value_len = max_value+1; if (RegEnumValue(key, i, name, &name_len, NULL, &type, value, &value_len) == ERROR_SUCCESS) { if ((type == REG_SZ) || (type == REG_EXPAND_SZ)) { + ht = (HashTable*)malloc(sizeof(HashTable)); if (!ht) { - ht = (HashTable*)malloc(sizeof(HashTable)); - zend_hash_init(ht, 0, NULL, ZVAL_INTERNAL_PTR_DTOR, 1); + return ret; } + zend_hash_init(ht, 0, NULL, ZVAL_INTERNAL_PTR_DTOR, 1); + data = (zval*)malloc(sizeof(zval)); + if (!data) { + return ret; + } INIT_PZVAL(data); Z_STRVAL_P(data) = zend_strndup(value, value_len-1); Z_STRLEN_P(data) = value_len-1; @@ -174,6 +179,9 @@ void UpdateIniFromRegistry(char *path TSRMLS_DC) if (!PW32G(registry_directories)) { PW32G(registry_directories) = (HashTable*)malloc(sizeof(HashTable)); + if (!PW32G(registry_directories)) { + return; + } zend_hash_init(PW32G(registry_directories), 0, NULL, delete_internal_hashtable, 1); if (!OpenPhpRegistryKey("\\Per Directory Values", &PW32G(registry_key))) { PW32G(registry_key) = NULL; |