From b5e72f440f8cd96af17b3d46918fdc0aea928fbf Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Wed, 19 Aug 2026 10:17:48 +0530 Subject: [PATCH 1/6] Fix date error messages for embedded NUL bytes --- ext/date/.DS_Store | Bin 0 -> 10244 bytes ext/date/php_date.c | 165 +++++++++--------- ext/date/php_date.h | 2 +- ext/date/tests/.DS_Store | Bin 0 -> 77828 bytes .../22993/dateInterval_create_null_byte.phpt | 14 ++ .../tests/22993/dateInterval_nul_byte.phpt | 18 ++ .../dateInterval_unserialize_null_byte.phpt | 14 ++ .../datePeriod_create_iso8601_null_byte.phpt | 14 ++ .../22993/dateTime_modify_embedded_null.phpt | 16 ++ .../tests/22993/date_interval_null_byte.phpt | 14 ++ .../22993/ini_date_timezone_null_byte.phpt | 10 ++ .../tests/22993/nul-byte-error-message.phpt | 14 ++ .../tests/22993/timezone_set_null_byte.phpt | 14 ++ 13 files changed, 214 insertions(+), 81 deletions(-) create mode 100644 ext/date/.DS_Store create mode 100644 ext/date/tests/.DS_Store create mode 100644 ext/date/tests/22993/dateInterval_create_null_byte.phpt create mode 100644 ext/date/tests/22993/dateInterval_nul_byte.phpt create mode 100644 ext/date/tests/22993/dateInterval_unserialize_null_byte.phpt create mode 100644 ext/date/tests/22993/datePeriod_create_iso8601_null_byte.phpt create mode 100644 ext/date/tests/22993/dateTime_modify_embedded_null.phpt create mode 100644 ext/date/tests/22993/date_interval_null_byte.phpt create mode 100644 ext/date/tests/22993/ini_date_timezone_null_byte.phpt create mode 100644 ext/date/tests/22993/nul-byte-error-message.phpt create mode 100644 ext/date/tests/22993/timezone_set_null_byte.phpt diff --git a/ext/date/.DS_Store b/ext/date/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..6f6fc404c8d4e1fd72d983869dd1ab026a8d35ca GIT binary patch literal 10244 zcmeHM%~BIV5bg;e%df%G(u0RBy?B5a$RCuKRDc6lLg_)Rm?Z(WTy|6WF$W4OXTA9V zK7=Qq#MjZUXBM(My96z&ETv|s+1|{|*E9Wf&xD>3k*Ez?>qIsYS*R?ti+H3I?&q2) znXtu%6u=X?bWAxKQh_!SqfLWhz%XDKFbo(536Hj+B%~2Ocs7fSg9NEOb zBov%PII{>d6d`8^&X&VTRFyPO!+>ER$$*Wfc{-$kd^(Ee?|WWw=y-vHe%?|w)Z9;5 z@TOz($ofyIsA0Zom|5DUecGiR+M@%i$484N+UP0rupUPn^+g-?kUDgN+MpISsZVWM zqjf6b{=tFVLR%Ya3sC!5VJEIF)BP=NO{zfOCjLrPyrDMMqiPv^-*jyySXq`Dx1g21 za1%=%*m)@Jtbn&a(Kes(LXHlTT#MyM1TCguT3|%;k&L{r5nS3_C-J!$BR)nj3n_DX z6vR<70UcGy-s+Nes?;a+w14^KSX9~dgjio zHES(cZ|f()u-2fbRe`YfZhP3s-ro-Ve$(~aT?ueoZ47zy%Jo~p zuoevbR!?H7PI<{H^YXJ;Fg(yCq9temgfXImTjRl8UypP$cJ51u}MvEO*_o%+Ei ztR6*#|6I|M`h5BPjJJqIAL?D-3;bh-pe}(A6=gZPHr8XFTfRhI8{@n?W7x+LYzzCV zE6;ydev_@?y^Lr-!g*H2NmiN=?TDtB=k89>n}~ak-`J{FCZf}J0NWLf%j`rAiMW<4 zh~g)&UypFzdXQm?VZbn87%&VN1`GqYn1Lx}o6YzCyI24Ie~TF~rWpnd17doozJn_h znarip!B-SE>N`{}ob-*9lo=x)JcQfjbv!=sb^NoiEzgn*`m3QFDJkJ-mvBgRoBvmS Z3^4h>$^ZFgThD+e=g-=$=Kq`j{{mW~*S`P& literal 0 HcmV?d00001 diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 9f9f0a6159ed..e390ccae2c59 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -531,8 +531,8 @@ static PHP_INI_MH(OnUpdate_date_timezone) if (new_value && !timelib_timezone_id_is_valid(ZSTR_VAL(new_value), DATE_TIMEZONEDB)) { php_error_docref( NULL, E_WARNING, - "Invalid date.timezone value '%s', using '%s' instead", - ZSTR_VAL(new_value), + "Invalid date.timezone value '%pS', using '%s' instead", + new_value, DATEG(default_timezone) ? DATEG(default_timezone) : "UTC" ); return FAILURE; @@ -2394,7 +2394,7 @@ static void php_date_get_current_time_with_fraction(time_t *sec, suseconds_t *us #endif } -PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, size_t time_str_len, const char *format, zval *timezone_object, int flags) /* {{{ */ +PHPAPI bool php_date_initialize(php_date_obj *dateobj, const zend_string *time_string, const char *format, zval *timezone_object, int flags) /* {{{ */ { timelib_time *now; timelib_tzinfo *tzi = NULL; @@ -2405,6 +2405,13 @@ PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, siz time_t sec; suseconds_t usec; int options = 0; + const char *time_str = ""; + size_t time_str_len = 0; + + if (time_string) { + time_str = ZSTR_VAL(time_string); + time_str_len = ZSTR_LEN(time_string); + } if (dateobj->time) { timelib_time_dtor(dateobj->time); @@ -2428,7 +2435,7 @@ PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, siz /* If called from a constructor throw an exception */ if ((flags & PHP_DATE_INIT_CTOR) && err && err->error_count) { /* spit out the first library error message, at least */ - zend_throw_exception_ex(date_ce_date_malformed_string_exception, 0, "Failed to parse time string (%s) at position %d (%c): %s", time_str, + zend_throw_exception_ex(date_ce_date_malformed_string_exception, 0, "Failed to parse time string (%pS) at position %d (%c): %s", time_string, err->error_messages[0].position, err->error_messages[0].character ? err->error_messages[0].character : ' ', err->error_messages[0].message); } if (err && err->error_count) { @@ -2572,17 +2579,16 @@ PHPAPI bool php_date_initialize_from_ts_double(php_date_obj *dateobj, double ts) PHP_FUNCTION(date_create) { zval *timezone_object = NULL; - char *time_str = NULL; - size_t time_str_len = 0; + zend_string *time_str = NULL; ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_STRING(time_str, time_str_len) + Z_PARAM_PATH_STR(time_str) Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone_object, date_ce_timezone) ZEND_PARSE_PARAMETERS_END(); php_date_instantiate(date_ce_date, return_value); - if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, NULL, timezone_object, 0)) { + if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, NULL, timezone_object, 0)) { zval_ptr_dtor(return_value); RETURN_FALSE; } @@ -2593,17 +2599,16 @@ PHP_FUNCTION(date_create) PHP_FUNCTION(date_create_immutable) { zval *timezone_object = NULL; - char *time_str = NULL; - size_t time_str_len = 0; + zend_string *time_str = NULL; ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_STRING(time_str, time_str_len) + Z_PARAM_PATH_STR(time_str) Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone_object, date_ce_timezone) ZEND_PARSE_PARAMETERS_END(); php_date_instantiate(date_ce_immutable, return_value); - if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, NULL, timezone_object, 0)) { + if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, NULL, timezone_object, 0)) { zval_ptr_dtor(return_value); RETURN_FALSE; } @@ -2614,12 +2619,13 @@ PHP_FUNCTION(date_create_immutable) PHP_FUNCTION(date_create_from_format) { zval *timezone_object = NULL; - char *time_str = NULL, *format_str = NULL; - size_t time_str_len = 0, format_str_len = 0; + zend_string *time_str = NULL; + char *format_str = NULL; + size_t format_str_len = 0; ZEND_PARSE_PARAMETERS_START(2, 3) Z_PARAM_STRING(format_str, format_str_len) - Z_PARAM_PATH(time_str, time_str_len) + Z_PARAM_PATH_STR(time_str) Z_PARAM_OPTIONAL Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone_object, date_ce_timezone) ZEND_PARSE_PARAMETERS_END(); @@ -2627,7 +2633,7 @@ PHP_FUNCTION(date_create_from_format) if (object_init_ex(return_value, execute_data->This.value.ce ? execute_data->This.value.ce : date_ce_date) != SUCCESS) { RETURN_THROWS(); } - if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, format_str, timezone_object, PHP_DATE_INIT_FORMAT)) { + if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, format_str, timezone_object, PHP_DATE_INIT_FORMAT)) { zval_ptr_dtor(return_value); RETURN_FALSE; } @@ -2638,12 +2644,13 @@ PHP_FUNCTION(date_create_from_format) PHP_FUNCTION(date_create_immutable_from_format) { zval *timezone_object = NULL; - char *time_str = NULL, *format_str = NULL; - size_t time_str_len = 0, format_str_len = 0; + char *format_str = NULL; + zend_string *time_str = NULL; + size_t format_str_len = 0; ZEND_PARSE_PARAMETERS_START(2, 3) Z_PARAM_STRING(format_str, format_str_len) - Z_PARAM_PATH(time_str, time_str_len) + Z_PARAM_PATH_STR(time_str) Z_PARAM_OPTIONAL Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone_object, date_ce_timezone) ZEND_PARSE_PARAMETERS_END(); @@ -2651,7 +2658,7 @@ PHP_FUNCTION(date_create_immutable_from_format) if (object_init_ex(return_value, execute_data->This.value.ce ? execute_data->This.value.ce : date_ce_immutable) != SUCCESS) { RETURN_THROWS(); } - if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, format_str, timezone_object, PHP_DATE_INIT_FORMAT)) { + if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, format_str, timezone_object, PHP_DATE_INIT_FORMAT)) { zval_ptr_dtor(return_value); RETURN_FALSE; } @@ -2662,16 +2669,15 @@ PHP_FUNCTION(date_create_immutable_from_format) PHP_METHOD(DateTime, __construct) { zval *timezone_object = NULL; - char *time_str = NULL; - size_t time_str_len = 0; + zend_string *time_str = NULL; ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_STRING(time_str, time_str_len) + Z_PARAM_PATH_STR(time_str) Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone_object, date_ce_timezone) ZEND_PARSE_PARAMETERS_END(); - php_date_initialize(Z_PHPDATE_P(ZEND_THIS), time_str, time_str_len, NULL, timezone_object, PHP_DATE_INIT_CTOR); + php_date_initialize(Z_PHPDATE_P(ZEND_THIS), time_str, NULL, timezone_object, PHP_DATE_INIT_CTOR); } /* }}} */ @@ -2679,16 +2685,15 @@ PHP_METHOD(DateTime, __construct) PHP_METHOD(DateTimeImmutable, __construct) { zval *timezone_object = NULL; - char *time_str = NULL; - size_t time_str_len = 0; + zend_string *time_str = NULL; ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_STRING(time_str, time_str_len) + Z_PARAM_PATH_STR(time_str) Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone_object, date_ce_timezone) ZEND_PARSE_PARAMETERS_END(); - php_date_initialize(Z_PHPDATE_P(ZEND_THIS), time_str, time_str_len, NULL, timezone_object, PHP_DATE_INIT_CTOR); + php_date_initialize(Z_PHPDATE_P(ZEND_THIS), time_str, NULL, timezone_object, PHP_DATE_INIT_CTOR); } /* }}} */ @@ -2883,7 +2888,7 @@ static bool php_date_initialize_from_hash(php_date_obj **dateobj, const HashTabl zend_string *tmp = zend_string_concat3( Z_STRVAL_P(z_date), Z_STRLEN_P(z_date), " ", 1, Z_STRVAL_P(z_timezone), Z_STRLEN_P(z_timezone)); - bool ret = php_date_initialize(*dateobj, ZSTR_VAL(tmp), ZSTR_LEN(tmp), NULL, NULL, 0); + bool ret = php_date_initialize(*dateobj, tmp, NULL, NULL, 0); zend_string_release(tmp); return ret; } @@ -2903,7 +2908,7 @@ static bool php_date_initialize_from_hash(php_date_obj **dateobj, const HashTabl tzobj->tzi.tz = tzi; tzobj->initialized = true; - ret = php_date_initialize(*dateobj, Z_STRVAL_P(z_date), Z_STRLEN_P(z_date), NULL, &tmp_obj, 0); + ret = php_date_initialize(*dateobj, Z_STR_P(z_date), NULL, &tmp_obj, 0); zval_ptr_dtor(&tmp_obj); return ret; } @@ -3258,7 +3263,7 @@ PHP_FUNCTION(date_format) } /* }}} */ -static bool php_date_modify(zval *object, char *modify, size_t modify_len) /* {{{ */ +static bool php_date_modify(zval *object, zend_string *modify) /* {{{ */ { php_date_obj *dateobj; timelib_time *tmp_time; @@ -3271,14 +3276,14 @@ static bool php_date_modify(zval *object, char *modify, size_t modify_len) /* {{ return false; } - tmp_time = timelib_strtotime(modify, modify_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); + tmp_time = timelib_strtotime(ZSTR_VAL(modify), ZSTR_LEN(modify), &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); /* update last errors and warnings */ update_errors_warnings(&err); if (err && err->error_count) { /* spit out the first library error message, at least */ - php_error_docref(NULL, E_WARNING, "Failed to parse time string (%s) at position %d (%c): %s", modify, + php_error_docref(NULL, E_WARNING, "Failed to parse time string (%pS) at position %d (%c): %s", modify, err->error_messages[0].position, err->error_messages[0].character ? err->error_messages[0].character : ' ', err->error_messages[0].message); @@ -3343,14 +3348,13 @@ static bool php_date_modify(zval *object, char *modify, size_t modify_len) /* {{ PHP_FUNCTION(date_modify) { zval *object; - char *modify; - size_t modify_len; + zend_string *modify; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &object, date_ce_date, &modify, &modify_len) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OS", &object, date_ce_date, &modify) == FAILURE) { RETURN_THROWS(); } - if (!php_date_modify(object, modify, modify_len)) { + if (!php_date_modify(object, modify)) { RETURN_FALSE; } @@ -3362,17 +3366,16 @@ PHP_FUNCTION(date_modify) PHP_METHOD(DateTime, modify) { zval *object; - char *modify; - size_t modify_len; + zend_string *modify; zend_error_handling zeh; object = ZEND_THIS; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STRING(modify, modify_len) + Z_PARAM_STR(modify) ZEND_PARSE_PARAMETERS_END(); zend_replace_error_handling(EH_THROW, date_ce_date_malformed_string_exception, &zeh); - if (!php_date_modify(object, modify, modify_len)) { + if (!php_date_modify(object, modify)) { zend_restore_error_handling(&zeh); RETURN_THROWS(); } @@ -3387,19 +3390,18 @@ PHP_METHOD(DateTime, modify) PHP_METHOD(DateTimeImmutable, modify) { zval *object, new_object; - char *modify; - size_t modify_len; + zend_string *modify; zend_error_handling zeh; object = ZEND_THIS; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STRING(modify, modify_len) + Z_PARAM_STR(modify) ZEND_PARSE_PARAMETERS_END(); date_clone_immutable(object, &new_object); zend_replace_error_handling(EH_THROW, date_ce_date_malformed_string_exception, &zeh); - if (!php_date_modify(&new_object, modify, modify_len)) { + if (!php_date_modify(&new_object, modify)) { zval_ptr_dtor(&new_object); zend_restore_error_handling(&zeh); RETURN_THROWS(); @@ -4451,7 +4453,7 @@ PHP_FUNCTION(timezone_location_get) } /* }}} */ -static bool date_interval_initialize(timelib_rel_time **rt, const char *format, size_t format_length) /* {{{ */ +static bool date_interval_initialize(timelib_rel_time **rt, const zend_string *format) /* {{{ */ { timelib_time *b = NULL, *e = NULL; timelib_rel_time *p = NULL; @@ -4459,10 +4461,10 @@ static bool date_interval_initialize(timelib_rel_time **rt, const char *format, bool retval = false; timelib_error_container *errors; - timelib_strtointerval(format, format_length, &b, &e, &p, &r, &errors); + timelib_strtointerval(ZSTR_VAL(format), ZSTR_LEN(format), &b, &e, &p, &r, &errors); if (errors->error_count > 0) { - zend_throw_exception_ex(date_ce_date_malformed_interval_string_exception, 0, "Unknown or bad format (%s)", format); + zend_throw_exception_ex(date_ce_date_malformed_interval_string_exception, 0, "Unknown or bad format (%pS)", format); retval = false; if (p) { timelib_rel_time_dtor(p); @@ -4478,7 +4480,7 @@ static bool date_interval_initialize(timelib_rel_time **rt, const char *format, *rt = timelib_diff(b, e); retval = true; } else { - zend_throw_exception_ex(date_ce_date_malformed_interval_string_exception, 0, "Failed to parse interval (%s)", format); + zend_throw_exception_ex(date_ce_date_malformed_interval_string_exception, 0, "Failed to parse interval (%pS)", format); retval = false; } } @@ -4624,10 +4626,10 @@ PHP_METHOD(DateInterval, __construct) timelib_rel_time *reltime; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(interval_string) + Z_PARAM_PATH_STR(interval_string) ZEND_PARSE_PARAMETERS_END(); - if (!date_interval_initialize(&reltime, ZSTR_VAL(interval_string), ZSTR_LEN(interval_string))) { + if (!date_interval_initialize(&reltime, interval_string)) { RETURN_THROWS(); } @@ -4649,9 +4651,15 @@ static void php_date_interval_initialize_from_hash(php_interval_obj *intobj, con time = timelib_strtotime(Z_STRVAL_P(date_str), Z_STRLEN_P(date_str), &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); if (err->error_count > 0) { + const zend_string *date_string; + if (Z_TYPE_P(date_str) == IS_STRING) { + date_string = Z_STR_P(date_str); + } else { + date_string = ZSTR_EMPTY_ALLOC(); + } zend_throw_error(NULL, - "Unknown or bad format (%s) at position %d (%c) while unserializing: %s", - Z_STRVAL_P(date_str), + "Unknown or bad format (%pS) at position %d (%c) while unserializing: %s", + date_string, err->error_messages[0].position, err->error_messages[0].character ? err->error_messages[0].character : ' ', err->error_messages[0].message); timelib_time_dtor(time); @@ -4891,20 +4899,20 @@ PHP_FUNCTION(date_interval_create_from_date_string) timelib_error_container *err = NULL; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(time_str) + Z_PARAM_PATH_STR(time_str) ZEND_PARSE_PARAMETERS_END(); time = timelib_strtotime(ZSTR_VAL(time_str), ZSTR_LEN(time_str), &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); if (err->error_count > 0) { - php_error_docref(NULL, E_WARNING, "Unknown or bad format (%s) at position %d (%c): %s", ZSTR_VAL(time_str), + php_error_docref(NULL, E_WARNING, "Unknown or bad format (%pS) at position %d (%c): %s", time_str, err->error_messages[0].position, err->error_messages[0].character ? err->error_messages[0].character : ' ', err->error_messages[0].message); RETVAL_FALSE; goto cleanup; } if (time->have_date || time->have_time || time->have_zone) { - php_error_docref(NULL, E_WARNING, "String '%s' contains non-relative elements", ZSTR_VAL(time_str)); + php_error_docref(NULL, E_WARNING, "String '%pS' contains non-relative elements", time_str); RETVAL_FALSE; goto cleanup; } @@ -4925,13 +4933,13 @@ PHP_METHOD(DateInterval, createFromDateString) timelib_error_container *err = NULL; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(time_str) + Z_PARAM_PATH_STR(time_str) ZEND_PARSE_PARAMETERS_END(); time = timelib_strtotime(ZSTR_VAL(time_str), ZSTR_LEN(time_str), &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); if (err->error_count > 0) { - zend_throw_error(date_ce_date_malformed_interval_string_exception, "Unknown or bad format (%s) at position %d (%c): %s", ZSTR_VAL(time_str), + zend_throw_error(date_ce_date_malformed_interval_string_exception, "Unknown or bad format (%pS) at position %d (%c): %s", time_str, err->error_messages[0].position, err->error_messages[0].character ? err->error_messages[0].character : ' ', err->error_messages[0].message); goto cleanup; } @@ -5037,7 +5045,7 @@ PHP_FUNCTION(date_interval_format) } /* }}} */ -static bool date_period_initialize(timelib_time **st, timelib_time **et, timelib_rel_time **d, zend_long *recurrences, const char *format, size_t format_length) /* {{{ */ +static bool date_period_initialize(timelib_time **st, timelib_time **et, timelib_rel_time **d, zend_long *recurrences, const zend_string *format) /* {{{ */ { timelib_time *b = NULL, *e = NULL; timelib_rel_time *p = NULL; @@ -5045,11 +5053,11 @@ static bool date_period_initialize(timelib_time **st, timelib_time **et, timelib timelib_error_container *errors; bool retval = false; - timelib_strtointerval(format, format_length, &b, &e, &p, &r, &errors); + timelib_strtointerval(ZSTR_VAL(format), ZSTR_LEN(format), &b, &e, &p, &r, &errors); if (errors->error_count > 0) { retval = false; - zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "Unknown or bad format (%s)", format); + zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "Unknown or bad format(%pS)", format); if (b) { timelib_time_dtor(b); } @@ -5070,27 +5078,27 @@ static bool date_period_initialize(timelib_time **st, timelib_time **et, timelib return retval; } /* }}} */ -static bool date_period_init_iso8601_string(php_period_obj *dpobj, zend_class_entry* base_ce, const char *isostr, size_t isostr_len, zend_long *recurrences) +static bool date_period_init_iso8601_string(php_period_obj *dpobj, zend_class_entry* base_ce, const zend_string *isostr, zend_long *recurrences) { - if (!date_period_initialize(&(dpobj->start), &(dpobj->end), &(dpobj->interval), recurrences, isostr, isostr_len)) { + if (!date_period_initialize(&(dpobj->start), &(dpobj->end), &(dpobj->interval), recurrences, isostr)) { return false; } if (dpobj->start == NULL) { zend_string *func = get_active_function_or_method_name(); - zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain a start date, \"%s\" given", ZSTR_VAL(func), isostr); + zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain a start date, \"%pS\" given", ZSTR_VAL(func), isostr); zend_string_release(func); return false; } if (dpobj->interval == NULL) { zend_string *func = get_active_function_or_method_name(); - zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain an interval, \"%s\" given", ZSTR_VAL(func), isostr); + zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain an interval, \"%pS\" given", ZSTR_VAL(func), isostr); zend_string_release(func); return false; } if (dpobj->end == NULL && *recurrences == 0) { zend_string *func = get_active_function_or_method_name(); - zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain an end date or a recurrence count, \"%s\" given", ZSTR_VAL(func), isostr); + zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain an end date or a recurrence count, \"%pS\" given", ZSTR_VAL(func), isostr); zend_string_release(func); return false; } @@ -5142,11 +5150,10 @@ PHP_METHOD(DatePeriod, createFromISO8601String) { php_period_obj *dpobj; zend_long recurrences = 0, options = 0; - char *isostr = NULL; - size_t isostr_len = 0; + zend_string *isostr = NULL; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STRING(isostr, isostr_len) + Z_PARAM_PATH_STR(isostr) Z_PARAM_OPTIONAL Z_PARAM_LONG(options) ZEND_PARSE_PARAMETERS_END(); @@ -5158,7 +5165,7 @@ PHP_METHOD(DatePeriod, createFromISO8601String) dpobj->current = NULL; - if (!date_period_init_iso8601_string(dpobj, date_ce_immutable, isostr, isostr_len, &recurrences)) { + if (!date_period_init_iso8601_string(dpobj, date_ce_immutable, isostr, &recurrences)) { RETURN_THROWS(); } @@ -5191,13 +5198,12 @@ PHP_METHOD(DatePeriod, __construct) php_date_obj *dateobj; zval *start, *end = NULL, *interval; zend_long recurrences = 0, options = 0; - char *isostr = NULL; - size_t isostr_len = 0; + zend_string *isostr = NULL; timelib_time *clone; if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "OOl|l", &start, date_ce_interface, &interval, date_ce_interval, &recurrences, &options) == FAILURE) { if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "OOO|l", &start, date_ce_interface, &interval, date_ce_interval, &end, date_ce_interface, &options) == FAILURE) { - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "s|l", &isostr, &isostr_len, &options) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "S|l", &isostr, &options) == FAILURE) { zend_type_error("DatePeriod::__construct() accepts (DateTimeInterface, DateInterval, int [, int]), or (DateTimeInterface, DateInterval, DateTime [, int]), or (string [, int]) as arguments"); RETURN_THROWS(); } @@ -5214,7 +5220,7 @@ PHP_METHOD(DatePeriod, __construct) RETURN_THROWS(); } - if (!date_period_init_iso8601_string(dpobj, date_ce_date, isostr, isostr_len, &recurrences)) { + if (!date_period_init_iso8601_string(dpobj, date_ce_date, isostr, &recurrences)) { RETURN_THROWS(); } } else { @@ -5458,22 +5464,21 @@ PHP_FUNCTION(timezone_abbreviations_list) /* {{{ Sets the default timezone used by all date/time functions in a script */ PHP_FUNCTION(date_default_timezone_set) { - char *zone; - size_t zone_len; + zend_string *zone; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STRING(zone, zone_len) + Z_PARAM_PATH_STR(zone) ZEND_PARSE_PARAMETERS_END(); - if (!timelib_timezone_id_is_valid(zone, DATE_TIMEZONEDB)) { - php_error_docref(NULL, E_NOTICE, "Timezone ID '%s' is invalid", zone); + if (!timelib_timezone_id_is_valid(ZSTR_VAL(zone), DATE_TIMEZONEDB)) { + php_error_docref(NULL, E_NOTICE, "Timezone ID '%pS' is invalid", zone); RETURN_FALSE; } if (DATEG(timezone)) { efree(DATEG(timezone)); DATEG(timezone) = NULL; } - DATEG(timezone) = estrndup(zone, zone_len); + DATEG(timezone) = estrndup(ZSTR_VAL(zone), ZSTR_LEN(zone)); RETURN_TRUE; } /* }}} */ diff --git a/ext/date/php_date.h b/ext/date/php_date.h index 97a49974f1a4..d409d9e7ae18 100644 --- a/ext/date/php_date.h +++ b/ext/date/php_date.h @@ -152,7 +152,7 @@ PHPAPI zend_class_entry *php_date_get_period_ce(void); #define PHP_DATE_INIT_FORMAT 0x02 PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object); -PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, size_t time_str_len, const char *format, zval *timezone_object, int flags); +PHPAPI bool php_date_initialize(php_date_obj *dateobj, const zend_string *time_str, const char *format, zval *timezone_object, int flags); PHPAPI void php_date_initialize_from_ts_long(php_date_obj *dateobj, zend_long sec, int usec); PHPAPI bool php_date_initialize_from_ts_double(php_date_obj *dateobj, double ts); diff --git a/ext/date/tests/.DS_Store b/ext/date/tests/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..81c50f5c71bc7dcb29aee898dac980f8be7b851f GIT binary patch literal 77828 zcmeHQ>vC1sk>0{M@dd=qV2o`n!p2G_ul=jz4ti>S287BLKxJS_4U`idR_KD zRaMP=cKhP7YUabLs$P))!}q&8s+qZ$t7`X-s+yCp`j`AWey08F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aYBFFiS>OehaC6YbTu* zQA^%^Vwku~Y_*@m>-Wx)_`M*(UR?Ek;~gBx{5GDYdquIW5Kq)Z_XN`(v4%UM_D)OY zF{!$kPd}M8NbMCZ3!)=EGjv6`byc%3?W|uFw$&d#ok!9o@BjpIN|n{E|PP-u!+S-|=fEiOF{rlkX}f z-_e}l-{&^JpWgg_H+>fa_%)+e<$DsZW|Fv+q0N7v+x&hyeczh@$2c2HbKcheKf1~P INAv&x0Vn(HM*si- literal 0 HcmV?d00001 diff --git a/ext/date/tests/22993/dateInterval_create_null_byte.phpt b/ext/date/tests/22993/dateInterval_create_null_byte.phpt new file mode 100644 index 000000000000..61eaf014a44a --- /dev/null +++ b/ext/date/tests/22993/dateInterval_create_null_byte.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-22993: DateInterval::createFromDateString() rejects embedded NUL byte +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught ValueError: DateInterval::createFromDateString(): Argument #1 ($datetime) must not contain any null bytes in %s:%d +Stack trace: +#0 %s(%d): DateInterval::createFromDateString('foo\x00bar') +#1 {main} + thrown in %s on line %d \ No newline at end of file diff --git a/ext/date/tests/22993/dateInterval_nul_byte.phpt b/ext/date/tests/22993/dateInterval_nul_byte.phpt new file mode 100644 index 000000000000..64e622eb4c5e --- /dev/null +++ b/ext/date/tests/22993/dateInterval_nul_byte.phpt @@ -0,0 +1,18 @@ +--TEST-- +GH-22993: DateInterval error message with embedded NUL byte +--FILE-- +getMessage(), PHP_EOL; +} + +?> +--EXPECTF-- +Fatal error: Uncaught ValueError: DateInterval::__construct(): Argument #1 ($duration) must not contain any null bytes in %s:%d +Stack trace: +#0 %s(%d): DateInterval->__construct('foo\x00bar') +#1 {main} + thrown in %s on line %d diff --git a/ext/date/tests/22993/dateInterval_unserialize_null_byte.phpt b/ext/date/tests/22993/dateInterval_unserialize_null_byte.phpt new file mode 100644 index 000000000000..c4bb09cd4e7f --- /dev/null +++ b/ext/date/tests/22993/dateInterval_unserialize_null_byte.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-22993: DateInterval unserialize() error message with embedded NUL byte +--FILE-- +getMessage(), PHP_EOL; +} + +?> +--EXPECTF-- +Unknown or bad format (foo%0bar) at position 0 (f) while unserializing: The timezone could not be found in the database diff --git a/ext/date/tests/22993/datePeriod_create_iso8601_null_byte.phpt b/ext/date/tests/22993/datePeriod_create_iso8601_null_byte.phpt new file mode 100644 index 000000000000..5c41a3f4e37d --- /dev/null +++ b/ext/date/tests/22993/datePeriod_create_iso8601_null_byte.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-22993: DatePeriod::createFromISO8601String() rejects embedded NUL byte +--FILE-- +getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +DatePeriod::createFromISO8601String(): Argument #1 ($specification) must not contain any null bytes \ No newline at end of file diff --git a/ext/date/tests/22993/dateTime_modify_embedded_null.phpt b/ext/date/tests/22993/dateTime_modify_embedded_null.phpt new file mode 100644 index 000000000000..900fa4937ddc --- /dev/null +++ b/ext/date/tests/22993/dateTime_modify_embedded_null.phpt @@ -0,0 +1,16 @@ +--TEST-- +GH-22993: DateTime::modify() error message with embedded NUL byte +--FILE-- +modify("foo\0bar"); +} catch (DateMalformedStringException $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECTF-- +DateTime::modify(): Failed to parse time string (foo%0bar) at position %s diff --git a/ext/date/tests/22993/date_interval_null_byte.phpt b/ext/date/tests/22993/date_interval_null_byte.phpt new file mode 100644 index 000000000000..0d1e9f909a0e --- /dev/null +++ b/ext/date/tests/22993/date_interval_null_byte.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-22993: date_interval_create_from_date_string() rejects embedded NUL byte +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught ValueError: date_interval_create_from_date_string(): Argument #1 ($datetime) must not contain any null bytes in %s:%d +Stack trace: +#0 %s(%d): date_interval_create_from_date_string('foo\x00bar') +#1 {main} + thrown in %s on line %d \ No newline at end of file diff --git a/ext/date/tests/22993/ini_date_timezone_null_byte.phpt b/ext/date/tests/22993/ini_date_timezone_null_byte.phpt new file mode 100644 index 000000000000..0d98638b190c --- /dev/null +++ b/ext/date/tests/22993/ini_date_timezone_null_byte.phpt @@ -0,0 +1,10 @@ +--TEST-- +GH-22993: ini_set() with embedded NUL byte in date.timezone +--FILE-- + +--EXPECTF-- +Warning: ini_set(): Invalid date.timezone value 'foo%0bar', using 'UTC' instead in %s on line %d diff --git a/ext/date/tests/22993/nul-byte-error-message.phpt b/ext/date/tests/22993/nul-byte-error-message.phpt new file mode 100644 index 000000000000..b7c178955cf8 --- /dev/null +++ b/ext/date/tests/22993/nul-byte-error-message.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-22993: DateTimeImmutable rejects embedded NUL byte +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught ValueError: DateTimeImmutable::__construct(): Argument #1 ($datetime) must not contain any null bytes in %s:%d +Stack trace: +#0 %s(%d): DateTimeImmutable->__construct('foo\x00bar') +#1 {main} + thrown in %s on line %d \ No newline at end of file diff --git a/ext/date/tests/22993/timezone_set_null_byte.phpt b/ext/date/tests/22993/timezone_set_null_byte.phpt new file mode 100644 index 000000000000..41bd5dd620b0 --- /dev/null +++ b/ext/date/tests/22993/timezone_set_null_byte.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-22993: date_default_timezone_set() rejects embedded NUL byte +--FILE-- +getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +date_default_timezone_set(): Argument #1 ($timezoneId) must not contain any null bytes \ No newline at end of file From 2e90eee0e31752bcdb54304fea17a9f62639b3f9 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Wed, 19 Aug 2026 13:31:35 +0530 Subject: [PATCH 2/6] Fix date error messages for embedded NUL bytes --- ext/date/php_date.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index e390ccae2c59..97b0b5a75a5b 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -5057,7 +5057,7 @@ static bool date_period_initialize(timelib_time **st, timelib_time **et, timelib if (errors->error_count > 0) { retval = false; - zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "Unknown or bad format(%pS)", format); + zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "Unknown or bad format (%pS)", format); if (b) { timelib_time_dtor(b); } From 396c168c5a0a81420bf766044da28379b5d7d991 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Wed, 19 Aug 2026 13:32:40 +0530 Subject: [PATCH 3/6] Fix date error messages for embedded NUL bytes --- ext/date/.DS_Store | Bin 10244 -> 0 bytes ext/date/tests/.DS_Store | Bin 77828 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 ext/date/.DS_Store delete mode 100644 ext/date/tests/.DS_Store diff --git a/ext/date/.DS_Store b/ext/date/.DS_Store deleted file mode 100644 index 6f6fc404c8d4e1fd72d983869dd1ab026a8d35ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10244 zcmeHM%~BIV5bg;e%df%G(u0RBy?B5a$RCuKRDc6lLg_)Rm?Z(WTy|6WF$W4OXTA9V zK7=Qq#MjZUXBM(My96z&ETv|s+1|{|*E9Wf&xD>3k*Ez?>qIsYS*R?ti+H3I?&q2) znXtu%6u=X?bWAxKQh_!SqfLWhz%XDKFbo(536Hj+B%~2Ocs7fSg9NEOb zBov%PII{>d6d`8^&X&VTRFyPO!+>ER$$*Wfc{-$kd^(Ee?|WWw=y-vHe%?|w)Z9;5 z@TOz($ofyIsA0Zom|5DUecGiR+M@%i$484N+UP0rupUPn^+g-?kUDgN+MpISsZVWM zqjf6b{=tFVLR%Ya3sC!5VJEIF)BP=NO{zfOCjLrPyrDMMqiPv^-*jyySXq`Dx1g21 za1%=%*m)@Jtbn&a(Kes(LXHlTT#MyM1TCguT3|%;k&L{r5nS3_C-J!$BR)nj3n_DX z6vR<70UcGy-s+Nes?;a+w14^KSX9~dgjio zHES(cZ|f()u-2fbRe`YfZhP3s-ro-Ve$(~aT?ueoZ47zy%Jo~p zuoevbR!?H7PI<{H^YXJ;Fg(yCq9temgfXImTjRl8UypP$cJ51u}MvEO*_o%+Ei ztR6*#|6I|M`h5BPjJJqIAL?D-3;bh-pe}(A6=gZPHr8XFTfRhI8{@n?W7x+LYzzCV zE6;ydev_@?y^Lr-!g*H2NmiN=?TDtB=k89>n}~ak-`J{FCZf}J0NWLf%j`rAiMW<4 zh~g)&UypFzdXQm?VZbn87%&VN1`GqYn1Lx}o6YzCyI24Ie~TF~rWpnd17doozJn_h znarip!B-SE>N`{}ob-*9lo=x)JcQfjbv!=sb^NoiEzgn*`m3QFDJkJ-mvBgRoBvmS Z3^4h>$^ZFgThD+e=g-=$=Kq`j{{mW~*S`P& diff --git a/ext/date/tests/.DS_Store b/ext/date/tests/.DS_Store deleted file mode 100644 index 81c50f5c71bc7dcb29aee898dac980f8be7b851f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 77828 zcmeHQ>vC1sk>0{M@dd=qV2o`n!p2G_ul=jz4ti>S287BLKxJS_4U`idR_KD zRaMP=cKhP7YUabLs$P))!}q&8s+qZ$t7`X-s+yCp`j`AWey08FIr*!Zs(S9<Jwh;ImKtSeh{CYv={H#~Q! zV*zZfEMj*|zDVq5fK~hFkFlRutlB?M{n-Yr+CR^^AzYf7ZD4gw_Kb-Cm5ev|dCm>t zlKc7R11RsLJ@tOhbmkBlcTRVQTMYC(SIqZKAO?K`XU60xr&a^F;!s&mx_8wYT5 zl6yq*wn!e8udgM7$0X{A<5Bs26N|RLPQ%`A4b4neFYcHza~%`|uzlu<(Xl)514x!4 zT9#iH3}`kZdphi&5FCpcQItPk9T)HE_>mz+d01bP{ZBG}jX`Pr;NS`$Kk(mn*5JR( z;eS$cX(e;0$pDR>Wx&3M^r~2178U}*5ffWlkd=M4P$V^yR*N6Ws@O+15*(4g&WENn zFr;-zqiAg-laY@p50`oTQIQ<}S#nvJbAqFW@e;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jjzbMr9K}TFjkHBJrnJnq9=FFrPE-bWF_}CB=IbLUeOVT zC^A+{(>|RMzP6{Ch2tKTE8bmp_30A`hJXrDrmJR7jk>liCO_IWLx< zp%)j+yQ4p#A2ce+Y3IkYjLJv*tk12Y)?#PKsT1x0xj*Hue2W~RdnH@VMjR$-3akM`7oeA{0&Z{pQNBUa5j&R3$*jFQ6 z?SngGXe{lU33tZQNOKUg&{!I24k~x<8}9UrG|fPrCv83Kr;p|z{98CP*gu+mVB#41 zXzpnZ8}1*?Jg{&K|7f0Q{Tl8c%@V}d`FCiuGTf5YO760+=_jK7tL$C$T!$aC9DJoi zC+SNxJFK2pLp|7w!j2BS#ix%FZD8KwY|T7h&tS={ysPT(W&JM|sgidCRNLiir}Y1L za%f3Tz87RwS>)vQr!^8H`Mi-{mbKi1tW1lHdGV}~{*jT!9u02eQrpPa*?A-VW0Bsm z={eS+xHW=m6zmZomzGZ%*%ypu+~dGHm}ic}c)zv$qDbQz1~3P^hW<@F`4)4rdLOj@ zyd)amG#cytsh@{fljx+kGWXFgv3=cU`pcp{Key?h$i-e}^9ho04+t3k)JAWIXl=hS zCau8ndBH~|=lXn(ckomNY`Hg9>=aw==i=6MRX^mDQNn#4SaYBFFiS>OehaC6YbTu* zQA^%^Vwku~Y_*@m>-Wx)_`M*(UR?Ek;~gBx{5GDYdquIW5Kq)Z_XN`(v4%UM_D)OY zF{!$kPd}M8NbMCZ3!)=EGjv6`byc%3?W|uFw$&d#ok!9o@BjpIN|n{E|PP-u!+S-|=fEiOF{rlkX}f z-_e}l-{&^JpWgg_H+>fa_%)+e<$DsZW|Fv+q0N7v+x&hyeczh@$2c2HbKcheKf1~P INAv&x0Vn(HM*si- From 2781f1b3a23529fe2d32e7033b97df02968314cc Mon Sep 17 00:00:00 2001 From: Arshid Date: Thu, 20 Aug 2026 09:58:19 +0530 Subject: [PATCH 4/6] Update ext/date/tests/22993/dateInterval_unserialize_null_byte.phpt Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com> --- .../tests/22993/dateInterval_unserialize_null_byte.phpt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/date/tests/22993/dateInterval_unserialize_null_byte.phpt b/ext/date/tests/22993/dateInterval_unserialize_null_byte.phpt index c4bb09cd4e7f..68d8a691b835 100644 --- a/ext/date/tests/22993/dateInterval_unserialize_null_byte.phpt +++ b/ext/date/tests/22993/dateInterval_unserialize_null_byte.phpt @@ -5,10 +5,10 @@ GH-22993: DateInterval unserialize() error message with embedded NUL byte try { unserialize('O:12:"DateInterval":2:{s:11:"from_string";b:1;s:11:"date_string";s:7:"foo' . "\0" . 'bar";}'); -} catch (Error $e) { - echo $e->getMessage(), PHP_EOL; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- -Unknown or bad format (foo%0bar) at position 0 (f) while unserializing: The timezone could not be found in the database +Error: Unknown or bad format (foo%0bar) at position 0 (f) while unserializing: The timezone could not be found in the database From 885ec7ff9431d1b3686bf488dc32dc19ef210286 Mon Sep 17 00:00:00 2001 From: Arshid Date: Thu, 20 Aug 2026 09:58:28 +0530 Subject: [PATCH 5/6] Update ext/date/tests/22993/datePeriod_create_iso8601_null_byte.phpt Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com> Update ext/date/tests/22993/dateTime_modify_embedded_null.phpt Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com> Update ext/date/tests/22993/dateInterval_create_null_byte.phpt Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com> Update ext/date/tests/22993/timezone_set_null_byte.phpt Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com> Update ext/date/tests/22993/nul-byte-error-message.phpt Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com> Update ext/date/tests/22993/dateInterval_nul_byte.phpt Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com> Update ext/date/tests/22993/date_interval_null_byte.phpt Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com> --- .../tests/22993/dateInterval_create_null_byte.phpt | 12 ++++++------ ext/date/tests/22993/dateInterval_nul_byte.phpt | 8 +++++++- .../22993/datePeriod_create_iso8601_null_byte.phpt | 6 +++--- .../tests/22993/dateTime_modify_embedded_null.phpt | 6 +++--- ext/date/tests/22993/date_interval_null_byte.phpt | 12 ++++++------ ext/date/tests/22993/nul-byte-error-message.phpt | 14 +++++++------- ext/date/tests/22993/timezone_set_null_byte.phpt | 6 +++--- 7 files changed, 35 insertions(+), 29 deletions(-) diff --git a/ext/date/tests/22993/dateInterval_create_null_byte.phpt b/ext/date/tests/22993/dateInterval_create_null_byte.phpt index 61eaf014a44a..844f52f546ab 100644 --- a/ext/date/tests/22993/dateInterval_create_null_byte.phpt +++ b/ext/date/tests/22993/dateInterval_create_null_byte.phpt @@ -3,12 +3,12 @@ GH-22993: DateInterval::createFromDateString() rejects embedded NUL byte --FILE-- getMessage(), "\n"; +} ?> --EXPECTF-- -Fatal error: Uncaught ValueError: DateInterval::createFromDateString(): Argument #1 ($datetime) must not contain any null bytes in %s:%d -Stack trace: -#0 %s(%d): DateInterval::createFromDateString('foo\x00bar') -#1 {main} - thrown in %s on line %d \ No newline at end of file +ValueError: DateInterval::createFromDateString(): Argument #1 ($datetime) must not contain any null bytes diff --git a/ext/date/tests/22993/dateInterval_nul_byte.phpt b/ext/date/tests/22993/dateInterval_nul_byte.phpt index 64e622eb4c5e..50c12f00a0db 100644 --- a/ext/date/tests/22993/dateInterval_nul_byte.phpt +++ b/ext/date/tests/22993/dateInterval_nul_byte.phpt @@ -15,4 +15,10 @@ Fatal error: Uncaught ValueError: DateInterval::__construct(): Argument #1 ($dur Stack trace: #0 %s(%d): DateInterval->__construct('foo\x00bar') #1 {main} - thrown in %s on line %d +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +?> +--EXPECTF-- +ValueError: DateInterval::__construct(): Argument #1 ($duration) must not contain any null bytes diff --git a/ext/date/tests/22993/datePeriod_create_iso8601_null_byte.phpt b/ext/date/tests/22993/datePeriod_create_iso8601_null_byte.phpt index 5c41a3f4e37d..7659146a1fea 100644 --- a/ext/date/tests/22993/datePeriod_create_iso8601_null_byte.phpt +++ b/ext/date/tests/22993/datePeriod_create_iso8601_null_byte.phpt @@ -5,10 +5,10 @@ GH-22993: DatePeriod::createFromISO8601String() rejects embedded NUL byte try { DatePeriod::createFromISO8601String("foo\0bar"); -} catch (ValueError $e) { - echo $e->getMessage(), PHP_EOL; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -DatePeriod::createFromISO8601String(): Argument #1 ($specification) must not contain any null bytes \ No newline at end of file +ValueError: DatePeriod::createFromISO8601String(): Argument #1 ($specification) must not contain any null bytes diff --git a/ext/date/tests/22993/dateTime_modify_embedded_null.phpt b/ext/date/tests/22993/dateTime_modify_embedded_null.phpt index 900fa4937ddc..68177303456e 100644 --- a/ext/date/tests/22993/dateTime_modify_embedded_null.phpt +++ b/ext/date/tests/22993/dateTime_modify_embedded_null.phpt @@ -7,10 +7,10 @@ $now = new DateTime(); try { $now->modify("foo\0bar"); -} catch (DateMalformedStringException $e) { - echo $e->getMessage(), "\n"; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECTF-- -DateTime::modify(): Failed to parse time string (foo%0bar) at position %s +DateMalformedStringException: DateTime::modify(): Failed to parse time string (foo%0bar) at position %s diff --git a/ext/date/tests/22993/date_interval_null_byte.phpt b/ext/date/tests/22993/date_interval_null_byte.phpt index 0d1e9f909a0e..a9622b985985 100644 --- a/ext/date/tests/22993/date_interval_null_byte.phpt +++ b/ext/date/tests/22993/date_interval_null_byte.phpt @@ -3,12 +3,12 @@ GH-22993: date_interval_create_from_date_string() rejects embedded NUL byte --FILE-- getMessage(), "\n"; +} ?> --EXPECTF-- -Fatal error: Uncaught ValueError: date_interval_create_from_date_string(): Argument #1 ($datetime) must not contain any null bytes in %s:%d -Stack trace: -#0 %s(%d): date_interval_create_from_date_string('foo\x00bar') -#1 {main} - thrown in %s on line %d \ No newline at end of file +ValueError: date_interval_create_from_date_string(): Argument #1 ($datetime) must not contain any null bytes diff --git a/ext/date/tests/22993/nul-byte-error-message.phpt b/ext/date/tests/22993/nul-byte-error-message.phpt index b7c178955cf8..45f2f0d26f57 100644 --- a/ext/date/tests/22993/nul-byte-error-message.phpt +++ b/ext/date/tests/22993/nul-byte-error-message.phpt @@ -3,12 +3,12 @@ GH-22993: DateTimeImmutable rejects embedded NUL byte --FILE-- getMessage(), "\n"; +} ?> ---EXPECTF-- -Fatal error: Uncaught ValueError: DateTimeImmutable::__construct(): Argument #1 ($datetime) must not contain any null bytes in %s:%d -Stack trace: -#0 %s(%d): DateTimeImmutable->__construct('foo\x00bar') -#1 {main} - thrown in %s on line %d \ No newline at end of file +--EXPECT-- +ValueError: DateTimeImmutable::__construct(): Argument #1 ($datetime) must not contain any null bytes diff --git a/ext/date/tests/22993/timezone_set_null_byte.phpt b/ext/date/tests/22993/timezone_set_null_byte.phpt index 41bd5dd620b0..37328f597a7a 100644 --- a/ext/date/tests/22993/timezone_set_null_byte.phpt +++ b/ext/date/tests/22993/timezone_set_null_byte.phpt @@ -5,10 +5,10 @@ GH-22993: date_default_timezone_set() rejects embedded NUL byte try { date_default_timezone_set("foo\0bar"); -} catch (ValueError $e) { - echo $e->getMessage(), PHP_EOL; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- -date_default_timezone_set(): Argument #1 ($timezoneId) must not contain any null bytes \ No newline at end of file +ValueError: date_default_timezone_set(): Argument #1 ($timezoneId) must not contain any null bytes From 1b98c659bd15c4892ec8aedc2a63de2266f40466 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Thu, 20 Aug 2026 10:13:27 +0530 Subject: [PATCH 6/6] Fix date error messages for embedded NUL bytes --- ext/date/tests/22993/dateInterval_nul_byte.phpt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ext/date/tests/22993/dateInterval_nul_byte.phpt b/ext/date/tests/22993/dateInterval_nul_byte.phpt index 50c12f00a0db..07d8ffb1ab02 100644 --- a/ext/date/tests/22993/dateInterval_nul_byte.phpt +++ b/ext/date/tests/22993/dateInterval_nul_byte.phpt @@ -5,16 +5,6 @@ GH-22993: DateInterval error message with embedded NUL byte try { new DateInterval("foo\0bar"); -} catch (DateMalformedIntervalStringException $e) { - echo $e->getMessage(), PHP_EOL; -} - -?> ---EXPECTF-- -Fatal error: Uncaught ValueError: DateInterval::__construct(): Argument #1 ($duration) must not contain any null bytes in %s:%d -Stack trace: -#0 %s(%d): DateInterval->__construct('foo\x00bar') -#1 {main} } catch (Throwable $e) { echo $e::class, ': ', $e->getMessage(), "\n"; }