com php-src: Merge branch 'PHP-5.6': ext/date/php_date.c

From: Date: Mon, 17 Aug 2015 17:28:46 +0000
Subject: com php-src: Merge branch 'PHP-5.6': ext/date/php_date.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-88567@lists.php.net to get a copy of this message
Commit: 61591ea636313a8f3807fc5f4950b7917cbb85a4 Author: Christoph M. Becker <cmb@php.net> Mon, 17 Aug 2015 19:28:46 +0200 Parents: aae9004ebdf42fbebafa461902009a936285415c 3ed58fb5d76813860fa96c020174c223e3b6d63e Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=61591ea636313a8f3807fc5f4950b7917cbb85a4 Log: Merge branch 'PHP-5.6' * PHP-5.6: Fix #70277: new DateTimeZone($foo) is ignoring text after null byte Resolved conflicts: ext/date/php_date.c Bugs: https://bugs.php.net/70277 Changed paths: MM ext/date/php_date.c Diff: diff --cc ext/date/php_date.c index ee30071,4eca65b..a8229c5 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@@ -3601,15 -3682,20 +3601,20 @@@ PHP_FUNCTION(date_diff } /* }}} */ - static int timezone_initialize(php_timezone_obj *tzobj, /*const*/ char *tz) /* {{{ */ -static int timezone_initialize(php_timezone_obj *tzobj, /*const*/ char *tz, size_t tz_len TSRMLS_DC) ++static int timezone_initialize(php_timezone_obj *tzobj, /*const*/ char *tz, size_t tz_len) /* {{{ */ { timelib_time *dummy_t = ecalloc(1, sizeof(timelib_time)); int dst, not_found; char *orig_tz = tz; + if (strlen(tz) != tz_len) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Timezone must not contain null bytes"); ++ php_error_docref(NULL, E_WARNING, "Timezone must not contain null bytes"); + return FAILURE; + } + dummy_t->z = timelib_parse_zone(&tz, &dst, dummy_t, &not_found, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); if (not_found) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown or bad timezone (%s)", orig_tz); + php_error_docref(NULL, E_WARNING, "Unknown or bad timezone (%s)", orig_tz); efree(dummy_t); return FAILURE; } else { @@@ -3626,15 -3712,14 +3631,15 @@@ PHP_FUNCTION(timezone_open) { char *tz; - int tz_len; + size_t tz_len; php_timezone_obj *tzobj; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &tz, &tz_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &tz, &tz_len) == FAILURE) { RETURN_FALSE; } - tzobj = zend_object_store_get_object(php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC) TSRMLS_CC); - if (SUCCESS != timezone_initialize(tzobj, tz, tz_len TSRMLS_CC)) { + tzobj = Z_PHPTIMEZONE_P(php_date_instantiate(date_ce_timezone, return_value)); - if (SUCCESS != timezone_initialize(tzobj, tz)) { ++ if (SUCCESS != timezone_initialize(tzobj, tz, tz_len)) { + zval_ptr_dtor(return_value); RETURN_FALSE; } } @@@ -3650,31 -3735,25 +3655,31 @@@ PHP_METHOD(DateTimeZone, __construct php_timezone_obj *tzobj; zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC); - if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &tz, &tz_len)) { - tzobj = zend_object_store_get_object(getThis() TSRMLS_CC); - if (FAILURE == timezone_initialize(tzobj, tz, tz_len TSRMLS_CC)) { - ZVAL_NULL(getThis()); - } + if (FAILURE == zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &tz, &tz_len)) { + return; } - zend_restore_error_handling(&error_handling TSRMLS_CC); + + zend_replace_error_handling(EH_THROW, NULL, &error_handling); + tzobj = Z_PHPTIMEZONE_P(getThis()); - timezone_initialize(tzobj, tz); ++ timezone_initialize(tzobj, tz, tz_len); + zend_restore_error_handling(&error_handling); } /* }}} */ -static int php_date_timezone_initialize_from_hash(zval **return_value, php_timezone_obj **tzobj, HashTable *myht TSRMLS_DC) +static int php_date_timezone_initialize_from_hash(zval **return_value, php_timezone_obj **tzobj, HashTable *myht) /* {{{ */ { - zval **z_timezone = NULL; - zval **z_timezone_type = NULL; + zval *z_timezone; + zval *z_timezone_type; - if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) { - if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) { - if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone), Z_STRLEN_PP(z_timezone) TSRMLS_CC)) { + if ((z_timezone_type = zend_hash_str_find(myht, "timezone_type", sizeof("timezone_type") - 1)) != NULL) { + if ((z_timezone = zend_hash_str_find(myht, "timezone", sizeof("timezone") - 1)) != NULL) { + if (Z_TYPE_P(z_timezone_type) != IS_LONG) { + return FAILURE; + } + if (Z_TYPE_P(z_timezone) != IS_STRING) { + return FAILURE; + } - if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_P(z_timezone))) { ++ if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_P(z_timezone), Z_STRLEN_P(z_timezone))) { return SUCCESS; } }

« previous php.cvs (#88567) next »