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

From: Date: Thu, 30 May 2019 18:15:58 +0000
Subject: com php-src: Merge branch 'PHP-7.4': ext/date/php_date.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-106469@lists.php.net to get a copy of this message
Commit: bc87424835a488a3b80f5eb61b455c2da1658d9b Author: Craig Duncan <duncan3dc@php.net> Thu, 30 May 2019 19:15:58 +0100 Parents: 0a6a350371832bbece79b55d12b78055cf3a3b11 a08b3b6d1924276662ea80d155c4f9e18147e1a0 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bc87424835a488a3b80f5eb61b455c2da1658d9b Log: Merge branch 'PHP-7.4' * PHP-7.4: Add a test for bug #65672 Ensure the internal properties cannot be overwritten Bugs: https://bugs.php.net/65672 Changed paths: MM ext/date/php_date.c Diff: diff --cc ext/date/php_date.c index e995b45,f7db8a2..7e04058 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@@ -5264,24 -5324,55 +5264,55 @@@ PHP_METHOD(DatePeriod, __wakeup } /* }}} */ + /* {{{ date_period_is_magic_property + * Common for date_period_read_property() and date_period_write_property() functions + */ + static int date_period_is_magic_property(zend_string *name) + { + if (zend_string_equals_literal(name, "recurrences") + || zend_string_equals_literal(name, "include_start_date") + || zend_string_equals_literal(name, "start") + || zend_string_equals_literal(name, "current") + || zend_string_equals_literal(name, "end") + || zend_string_equals_literal(name, "interval") + ) { + return 1; + } + return 0; + } + /* }}} */ + /* {{{ date_period_read_property */ -static zval *date_period_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +static zval *date_period_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) { if (type != BP_VAR_IS && type != BP_VAR_R) { - zend_throw_error(NULL, "Retrieval of DatePeriod properties for modification is unsupported"); - return &EG(uninitialized_zval); + zend_string *name = zval_get_string(member); + if (date_period_is_magic_property(name)) { + zend_throw_error(NULL, "Retrieval of DatePeriod->%s for modification is unsupported", ZSTR_VAL(name)); + zend_string_release(name); + return &EG(uninitialized_zval); + } + zend_string_release(name); } - Z_OBJPROP_P(object); /* build properties hash table */ + object->handlers->get_properties(object); /* build properties hash table */ - return zend_std_read_property(object, member, type, cache_slot, rv); + return zend_std_read_property(object, name, type, cache_slot, rv); } /* }}} */ /* {{{ date_period_write_property */ -static zval *date_period_write_property(zval *object, zval *member, zval *value, void **cache_slot) +static zval *date_period_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { - zend_throw_error(NULL, "Writing to DatePeriod properties is unsupported"); + zend_string *name = zval_get_string(member); + if (date_period_is_magic_property(name)) { + zend_throw_error(NULL, "Writing to DatePeriod->%s is unsupported", ZSTR_VAL(name)); + zend_string_release(name); + return value; + } + zend_string_release(name); + + std_object_handlers.write_property(object, member, value, cache_slot); return value; } /* }}} */

« previous php.cvs (#106469) next »