From: Dmitry Stogov Date: Tue, 13 May 2014 11:24:40 +0000 (+0400) Subject: Merge branch 'master' into phpng X-Git-Tag: POST_PHPNG_MERGE~374^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7fcd4064c01d607958456f2771b12a8ade508208;p=php Merge branch 'master' into phpng * master: (41 commits) fix test - output can be chunked fix test fix test Fixed test for commit 997be125eb0228c5b1b6dd278f617791e71192c6 Add bug fix to NEWS Update UPGRADING according to bug fix fix test improve CURL tests to allow testing without separate server improve CURL tests to allow testing without separate server Fixed bug #67199 mb_regex_encoding mishmash Fix bug #67248 (imageaffinematrixget missing check of parameters) Fix bug #67247 spl_fixedarray_resize integer overflow fix news add tests stuff to README Updated NEWS Fix Linux specific fail in error traces (cherry-picked and fix for bug #67245) Linux apparently does not like memcpy in overlapping regions... - Fixed off-by-one in phar_build (patch by crrodriguez at opensuse dot org) - Move checking - Fixed missing NULL check in SimpleXMLElement::xpath() - Fixed missing NULL check ... Conflicts: ext/bz2/bz2.c ext/gd/gd.c ext/mbstring/php_mbregex.c ext/session/tests/031.phpt ext/simplexml/simplexml.c ext/spl/spl_fixedarray.c --- 7fcd4064c01d607958456f2771b12a8ade508208 diff --cc ext/bz2/bz2.c index 8431b5214b,f310289d73..bd4ac68d1d --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@@ -226,10 -226,13 +226,13 @@@ PHP_BZ2_API php_stream *_php_stream_bz2 #ifdef VIRTUAL_DIR virtual_filepath_ex(path, &path_copy, NULL TSRMLS_CC); #else - path_copy = estrdup(path); + path_copy = path; -#endif +#endif if (php_check_open_basedir(path_copy TSRMLS_CC)) { + #ifdef VIRTUAL_DIR + efree(path_copy); + #endif return NULL; } @@@ -237,13 -240,12 +240,20 @@@ bz_file = BZ2_bzopen(path_copy, mode); if (opened_path && bz_file) { - *opened_path = estrdup(path_copy); ++#ifdef VIRTUAL_DIR ++ *opened_path = path_copy; + path_copy = NULL; ++#else + *opened_path = estrdup(path_copy); ++#endif } + + #ifdef VIRTUAL_DIR - efree(path_copy); + if (path_copy) { + efree(path_copy); + } + #endif + path_copy = NULL; if (bz_file == NULL) { /* that didn't work, so try and get something from the network/wrapper */ diff --cc ext/gd/gd.c index 54cf68edce,f67e80bf8e..d7994476f0 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@@ -5251,8 -5274,8 +5251,8 @@@ PHP_FUNCTION(imageaffinematrixget { double affine[6]; long type; - zval *options; + zval *options = NULL; - zval **tmp; + zval *tmp; int res = GD_FALSE, i; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|z", &type, &options) == FAILURE) { @@@ -5308,7 -5333,11 +5308,11 @@@ case GD_AFFINE_SHEAR_VERTICAL: { double angle; + if (!options) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number is expected as option"); + RETURN_FALSE; + } - convert_to_double_ex(&options); + convert_to_double_ex(options); angle = Z_DVAL_P(options); if (type == GD_AFFINE_SHEAR_HORIZONTAL) { diff --cc ext/mbstring/php_mbregex.c index c0e61aa660,9ea2970393..24c1ff9019 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@@ -63,10 -64,10 +63,10 @@@ static void php_mb_regex_free_cache(zva /* {{{ _php_mb_regex_globals_ctor */ static int _php_mb_regex_globals_ctor(zend_mb_regex_globals *pglobals TSRMLS_DC) { - pglobals->default_mbctype = ONIG_ENCODING_EUC_JP; - pglobals->current_mbctype = ONIG_ENCODING_EUC_JP; + pglobals->default_mbctype = ONIG_ENCODING_UTF8; + pglobals->current_mbctype = ONIG_ENCODING_UTF8; - zend_hash_init(&(pglobals->ht_rc), 0, NULL, (void (*)(void *)) php_mb_regex_free_cache, 1); - pglobals->search_str = (zval*) NULL; + zend_hash_init(&(pglobals->ht_rc), 0, NULL, php_mb_regex_free_cache, 1); + ZVAL_UNDEF(&pglobals->search_str); pglobals->search_re = (php_mb_regex_t*)NULL; pglobals->search_pos = 0; pglobals->search_regs = (OnigRegion*)NULL; diff --cc ext/phar/phar_object.c index 978b036c67,75aadfbc54..d73f6ad641 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@@ -1469,16 -1477,16 +1469,16 @@@ static int phar_build(zend_object_itera } close_fp = 0; - opened = (char *) estrndup(str, sizeof("[stream]") + 1); + opened = (char *) estrndup(str, sizeof("[stream]") - 1); goto after_open_fp; case IS_OBJECT: - if (instanceof_function(Z_OBJCE_PP(value), spl_ce_SplFileInfo TSRMLS_CC)) { + if (instanceof_function(Z_OBJCE_P(value), spl_ce_SplFileInfo TSRMLS_CC)) { char *test = NULL; zval dummy; - spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(*value TSRMLS_CC); + spl_filesystem_object *intern = (spl_filesystem_object*)((char*)Z_OBJ_P(value) - Z_OBJ_P(value)->handlers->offset); if (!base_len) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Iterator %v returns an SplFileInfo object, so base directory must be specified", ce->name); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Iterator %v returns an SplFileInfo object, so base directory must be specified", ce->name->val); return ZEND_HASH_APPLY_STOP; } diff --cc ext/session/session.c index a21262c17d,8051758c12..c39e954ded --- a/ext/session/session.c +++ b/ext/session/session.c @@@ -1572,10 -1603,10 +1572,10 @@@ PHPAPI void php_session_start(TSRMLS_D } } - /* Finally check session id for dangarous characters + /* Finally check session id for dangerous characters * Security note: session id may be embedded in HTML pages.*/ - if (PS(id) && strpbrk(PS(id), "\r\n\t <>'\"\\")) { - efree(PS(id)); + if (PS(id) && strpbrk(PS(id)->val, "\r\n\t <>'\"\\")) { + STR_RELEASE(PS(id)); PS(id) = NULL; } diff --cc ext/simplexml/simplexml.c index 099d9722bd,a915862ec4..f9f7452bf4 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@@ -1512,9 -1536,7 +1515,7 @@@ SXE_METHOD(getDocNamespaces return; } - array_init(return_value); - - sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); + sxe = Z_SXEOBJ_P(getThis()); if(from_root){ node = xmlDocGetRootElement((xmlDocPtr)sxe->document->ptr); }else{ diff --cc ext/spl/spl_fixedarray.c index 9983025165,2c5d5f626c..6936845b32 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@@ -120,8 -116,8 +120,8 @@@ static void spl_fixedarray_resize(spl_f array->elements = NULL; } } else if (size > array->size) { - array->elements = erealloc(array->elements, sizeof(zval) * size); - array->elements = safe_erealloc(array->elements, size, sizeof(zval *), 0); - memset(array->elements + array->size, '\0', sizeof(zval *) * (size - array->size)); ++ array->elements = safe_erealloc(array->elements, size, sizeof(zval), 0); + memset(array->elements + array->size, '\0', sizeof(zval) * (size - array->size)); } else { /* size < array->size */ long i; diff --cc ext/standard/streamsfuncs.c index 81afb2228e,68b4cceaaa..1d59a97a94 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@@ -40,6 -40,8 +40,8 @@@ typedef unsigned long long php_timeout_ typedef unsigned __int64 php_timeout_ull; #endif -#define GET_CTX_OPT(stream, wrapper, name, val) (stream->context && SUCCESS == php_stream_context_get_option(stream->context, wrapper, name, &val)) ++#define GET_CTX_OPT(stream, wrapper, name, val) (stream->context && NULL != (val = php_stream_context_get_option(stream->context, wrapper, name))) + static php_stream_context *decode_context_param(zval *contextresource TSRMLS_DC); /* Streams based network functions */ @@@ -1451,11 -1500,22 +1453,22 @@@ PHP_FUNCTION(stream_socket_enable_crypt RETURN_FALSE; } - php_stream_from_zval(stream, &zstream); + php_stream_from_zval(stream, zstream); - if (ZEND_NUM_ARGS() >= 3) { + if (enable) { + if (ZEND_NUM_ARGS() < 3 || cryptokindnull) { - zval **val; ++ zval *val; + + if (!GET_CTX_OPT(stream, "ssl", "crypto_method", val)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "When enabling encryption you must specify the crypto type"); + RETURN_FALSE; + } + - cryptokind = Z_LVAL_PP(val); ++ cryptokind = Z_LVAL_P(val); + } + if (zsessstream) { - php_stream_from_zval(sessstream, &zsessstream); + php_stream_from_zval(sessstream, zsessstream); } if (php_stream_xport_crypto_setup(stream, cryptokind, sessstream TSRMLS_CC) < 0) {