ext/date truncates error messages with null bytes
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
date_throw_uninitialized_error() (C function):
<?php
$o = new class extends DateTime {
public function __construct() {}
};
var_dump(get_class($o));
$o->format("");
OnUpdate_date_timezone ini handler:
<?php
ini_set("date.timezone", "foo\0bar");
php_date_initialize() (C function):
<?php
new DateTimeImmutable("foo\0bar");
php_date_modify() (C function):
<?php
$now = new DateTime();
$now->modify("foo\0bar");
date_interval_initialize() (C function):
<?php
new DateInterval("foo\0bar");
php_date_interval_initialize_from_hash() (C function):
<?php
var_dump(unserialize("O:12:\"DateInterval\":2:{s:11:\"from_string\";b:1;s:11:\"date_string\";s:7:\"foo\0bar\";}"));
date_interval_create_from_date_string() (C function):
<?php
date_interval_create_from_date_string("foo\0bar");
DateInterval::createFromDateString():
<?php
DateInterval::createFromDateString("foo\0bar");
date_period_initialize() (C function):
<?php
DatePeriod::createFromISO8601String("foo\0bar");
date_period_initialize() (C function):
<?php
DatePeriod::createFromISO8601String("foo\0bar");
date_default_timezone_set():
<?php
date_default_timezone_set("foo\0bar");
date_period_unset_property() (C function):
<?php
$o = new class() extends DatePeriod {
public function __construct() {}
};
unset($o->start);
Tested with 3v4l
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the ext/date implementation at the named C functions and reproduce the listed null-byte cases with the provided PHP snippets. Trace how each error message is built, then add coverage for the affected paths and verify that the resulting messages preserve the relevant input; run the date extension tests to confirm all listed entry points.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100