Skip to content

Commit 172b734

Browse files
committed
Update NEWS
2 parents e05897f + 209ea3f commit 172b734

File tree

3 files changed

+95
-3
lines changed

3 files changed

+95
-3
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ PHP NEWS
1212
. Fixed Haiku ZTS builds. (David Carlier)
1313

1414
- Date:
15+
. Fixed bug #72963 (Null-byte injection in CreateFromFormat and related
16+
functions). (Derick)
1517
. Fixed bug GH-8471 (Segmentation fault when converting immutable and mutable
1618
DateTime instances created using reflection). (Derick)
1719

ext/date/php_date.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,7 +2382,7 @@ PHP_FUNCTION(date_create_from_format)
23822382

23832383
ZEND_PARSE_PARAMETERS_START(2, 3)
23842384
Z_PARAM_STRING(format_str, format_str_len)
2385-
Z_PARAM_STRING(time_str, time_str_len)
2385+
Z_PARAM_PATH(time_str, time_str_len)
23862386
Z_PARAM_OPTIONAL
23872387
Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone_object, date_ce_timezone)
23882388
ZEND_PARSE_PARAMETERS_END();
@@ -2404,7 +2404,7 @@ PHP_FUNCTION(date_create_immutable_from_format)
24042404

24052405
ZEND_PARSE_PARAMETERS_START(2, 3)
24062406
Z_PARAM_STRING(format_str, format_str_len)
2407-
Z_PARAM_STRING(time_str, time_str_len)
2407+
Z_PARAM_PATH(time_str, time_str_len)
24082408
Z_PARAM_OPTIONAL
24092409
Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone_object, date_ce_timezone)
24102410
ZEND_PARSE_PARAMETERS_END();
@@ -2804,7 +2804,7 @@ PHP_FUNCTION(date_parse_from_format)
28042804

28052805
ZEND_PARSE_PARAMETERS_START(2, 2)
28062806
Z_PARAM_STR(format)
2807-
Z_PARAM_STR(date)
2807+
Z_PARAM_PATH_STR(date)
28082808
ZEND_PARSE_PARAMETERS_END();
28092809

28102810
parsed_time = timelib_parse_from_format(ZSTR_VAL(format), ZSTR_VAL(date), ZSTR_LEN(date), &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);

ext/date/tests/bug72963.phpt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
--TEST--
2+
Bug #72963 (Null-byte injection in CreateFromFormat and related functions)
3+
--FILE--
4+
<?php
5+
$strings = [
6+
'8/8/2016',
7+
"8/8/2016\0asf",
8+
];
9+
10+
foreach ($strings as $string) {
11+
$d1 = $d2 = $d3 = NULL;
12+
echo "\nCovering string: ", addslashes($string), "\n\n";
13+
14+
try {
15+
$d1 = DateTime::createFromFormat('!m/d/Y', $string);
16+
} catch (ValueError $v) {
17+
echo $v->getMessage(), "\n";
18+
}
19+
20+
try {
21+
$d2 = DateTimeImmutable::createFromFormat('!m/d/Y', $string);
22+
} catch (ValueError $v) {
23+
echo $v->getMessage(), "\n";
24+
}
25+
26+
try {
27+
$d3 = date_parse_from_format('m/d/Y', $string);
28+
} catch (ValueError $v) {
29+
echo $v->getMessage(), "\n";
30+
}
31+
32+
var_dump($d1, $d2, $d3);
33+
}
34+
?>
35+
--EXPECT--
36+
Covering string: 8/8/2016
37+
38+
object(DateTime)#1 (3) {
39+
["date"]=>
40+
string(26) "2016-08-08 00:00:00.000000"
41+
["timezone_type"]=>
42+
int(3)
43+
["timezone"]=>
44+
string(3) "UTC"
45+
}
46+
object(DateTimeImmutable)#2 (3) {
47+
["date"]=>
48+
string(26) "2016-08-08 00:00:00.000000"
49+
["timezone_type"]=>
50+
int(3)
51+
["timezone"]=>
52+
string(3) "UTC"
53+
}
54+
array(12) {
55+
["year"]=>
56+
int(2016)
57+
["month"]=>
58+
int(8)
59+
["day"]=>
60+
int(8)
61+
["hour"]=>
62+
bool(false)
63+
["minute"]=>
64+
bool(false)
65+
["second"]=>
66+
bool(false)
67+
["fraction"]=>
68+
bool(false)
69+
["warning_count"]=>
70+
int(0)
71+
["warnings"]=>
72+
array(0) {
73+
}
74+
["error_count"]=>
75+
int(0)
76+
["errors"]=>
77+
array(0) {
78+
}
79+
["is_localtime"]=>
80+
bool(false)
81+
}
82+
83+
Covering string: 8/8/2016\0asf
84+
85+
DateTime::createFromFormat(): Argument #2 ($datetime) must not contain any null bytes
86+
DateTimeImmutable::createFromFormat(): Argument #2 ($datetime) must not contain any null bytes
87+
date_parse_from_format(): Argument #2 ($datetime) must not contain any null bytes
88+
NULL
89+
NULL
90+
NULL

0 commit comments

Comments
 (0)