@@ -3682,12 +3682,17 @@ PHP_FUNCTION(date_diff)
3682
3682
}
3683
3683
/* }}} */
3684
3684
3685
- static int timezone_initialize (php_timezone_obj * tzobj , /*const*/ char * tz TSRMLS_DC )
3685
+ static int timezone_initialize (php_timezone_obj * tzobj , /*const*/ char * tz , size_t tz_len TSRMLS_DC )
3686
3686
{
3687
3687
timelib_time * dummy_t = ecalloc (1 , sizeof (timelib_time ));
3688
3688
int dst , not_found ;
3689
3689
char * orig_tz = tz ;
3690
3690
3691
+ if (strlen (tz ) != tz_len ) {
3692
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Timezone must not contain null bytes" );
3693
+ return FAILURE ;
3694
+ }
3695
+
3691
3696
dummy_t -> z = timelib_parse_zone (& tz , & dst , dummy_t , & not_found , DATE_TIMEZONEDB , php_date_parse_tzfile_wrapper );
3692
3697
if (not_found ) {
3693
3698
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Unknown or bad timezone (%s)" , orig_tz );
@@ -3714,7 +3719,7 @@ PHP_FUNCTION(timezone_open)
3714
3719
RETURN_FALSE ;
3715
3720
}
3716
3721
tzobj = zend_object_store_get_object (php_date_instantiate (date_ce_timezone , return_value TSRMLS_CC ) TSRMLS_CC );
3717
- if (SUCCESS != timezone_initialize (tzobj , tz TSRMLS_CC )) {
3722
+ if (SUCCESS != timezone_initialize (tzobj , tz , tz_len TSRMLS_CC )) {
3718
3723
RETURN_FALSE ;
3719
3724
}
3720
3725
}
@@ -3733,7 +3738,7 @@ PHP_METHOD(DateTimeZone, __construct)
3733
3738
zend_replace_error_handling (EH_THROW , NULL , & error_handling TSRMLS_CC );
3734
3739
if (SUCCESS == zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "s" , & tz , & tz_len )) {
3735
3740
tzobj = zend_object_store_get_object (getThis () TSRMLS_CC );
3736
- if (FAILURE == timezone_initialize (tzobj , tz TSRMLS_CC )) {
3741
+ if (FAILURE == timezone_initialize (tzobj , tz , tz_len TSRMLS_CC )) {
3737
3742
ZVAL_NULL (getThis ());
3738
3743
}
3739
3744
}
@@ -3748,7 +3753,7 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
3748
3753
3749
3754
if (zend_hash_find (myht , "timezone_type" , 14 , (void * * ) & z_timezone_type ) == SUCCESS && Z_TYPE_PP (z_timezone_type ) == IS_LONG ) {
3750
3755
if (zend_hash_find (myht , "timezone" , 9 , (void * * ) & z_timezone ) == SUCCESS && Z_TYPE_PP (z_timezone ) == IS_STRING ) {
3751
- if (SUCCESS == timezone_initialize (* tzobj , Z_STRVAL_PP (z_timezone ) TSRMLS_CC )) {
3756
+ if (SUCCESS == timezone_initialize (* tzobj , Z_STRVAL_PP (z_timezone ), Z_STRLEN_PP ( z_timezone ) TSRMLS_CC )) {
3752
3757
return SUCCESS ;
3753
3758
}
3754
3759
}
0 commit comments