Skip to content

Commit c2b8a72

Browse files
committed
Merge branch 'PHP-5.5' of https://git.php.net/repository/php-src into PHP-5.5
# By David Soria Parra (6) and others # Via David Soria Parra (5) and Michael Wallner (1) * 'PHP-5.5' of https://git.php.net/repository/php-src: Revert "EmptyIterator now implements Countable; fixes bug 60577" RFC 6598 reserved ip range starts at 100.64.0.0 fix a very rare case of use of uninitialized value combined with a memleak NEWS for added reserved ip addresses according to RFC 6598 Add RFC 6598 IPs to reserved addresses NEWS for #60577 NEWS for bug #64441 Fix bug #64441 (FILTER_VALIDATE_URL rejects fully qualified domain names) EmptyIterator now implements Countable; fixes bug 60577 News for bugfix #64157 Bug 64157 Changed error message to make sense
2 parents e06a712 + 94e4c4d commit c2b8a72

File tree

7 files changed

+38
-7
lines changed

7 files changed

+38
-7
lines changed

ext/date/lib/parse_date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25002,7 +25002,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
2500225002
TIMELIB_CHECK_NUMBER;
2500325003
sec = timelib_get_nr_ex((char **) &ptr, 2, &length);
2500425004
if (sec == TIMELIB_UNSET || length != 2) {
25005-
add_pbf_error(s, "A two second minute could not be found", string, begin);
25005+
add_pbf_error(s, "A two digit second could not be found", string, begin);
2500625006
} else {
2500725007
s->time->s = sec;
2500825008
}

ext/date/lib/parse_date.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
20092009
TIMELIB_CHECK_NUMBER;
20102010
sec = timelib_get_nr_ex((char **) &ptr, 2, &length);
20112011
if (sec == TIMELIB_UNSET || length != 2) {
2012-
add_pbf_error(s, "A two second minute could not be found", string, begin);
2012+
add_pbf_error(s, "A two digit second could not be found", string, begin);
20132013
} else {
20142014
s->time->s = sec;
20152015
}

ext/date/tests/bug64157.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Test for bug #64157: DateTime::createFromFormat() reports confusing error message
3+
--CREDITS--
4+
Boro Sitnikovski <buritomath@yahoo.com>
5+
--INI--
6+
date.timezone = UTC
7+
--FILE--
8+
<?php
9+
DateTime::createFromFormat('s', '0');
10+
$lastErrors = DateTime::getLastErrors();
11+
print_r($lastErrors['errors'][0]);
12+
?>
13+
--EXPECT--
14+
A two digit second could not be found

ext/filter/logical_filters.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,6 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
484484
}
485485
s++;
486486
}
487-
488-
if (*(e - 1) == '.') {
489-
goto bad_url;
490-
}
491487
}
492488

493489
if (
@@ -718,6 +714,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
718714
if (flags & FILTER_FLAG_NO_RES_RANGE) {
719715
if (
720716
(ip[0] == 0) ||
717+
(ip[0] == 100 && (ip[1] >= 64 || ip[1] <= 127)) ||
721718
(ip[0] == 128 && ip[1] == 0) ||
722719
(ip[0] == 191 && ip[1] == 255) ||
723720
(ip[0] == 169 && ip[1] == 254) ||

ext/filter/tests/018.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var_dump(filter_var("192.168.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE
1515
var_dump(filter_var("192.0.34.166", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE));
1616
var_dump(filter_var("127.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
1717
var_dump(filter_var("192.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
18+
var_dump(filter_var("100.0.0.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
19+
var_dump(filter_var("100.127.255.255", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
1820
var_dump(filter_var("192.0.34.166", FILTER_VALIDATE_IP));
1921
var_dump(filter_var("256.1237.123.1", FILTER_VALIDATE_IP));
2022
var_dump(filter_var("255.255.255.255", FILTER_VALIDATE_IP));
@@ -40,6 +42,8 @@ bool(false)
4042
string(12) "192.0.34.166"
4143
bool(false)
4244
string(9) "192.0.0.1"
45+
bool(false)
46+
bool(false)
4347
string(12) "192.0.34.166"
4448
bool(false)
4549
string(15) "255.255.255.255"

ext/filter/tests/bug64441.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
bug 64441, FILTER_VALIDATE_URL will invalidate a hostname that ended by dot
3+
--SKIPIF--
4+
<?php if (!extension_loaded("filter")) die("skip"); ?>
5+
--FILE--
6+
<?php
7+
var_dump(filter_var('http://example.com./', FILTER_VALIDATE_URL));
8+
var_dump(filter_var('http://example.com/', FILTER_VALIDATE_URL));
9+
--EXPECT--
10+
string(20) "http://example.com./"
11+
string(19) "http://example.com/"

main/fopen_wrappers.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,12 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co
775775
* we cannot cannot getcwd() and the requested,
776776
* relatively referenced file is accessible */
777777
copy_len = strlen(filepath) > MAXPATHLEN - 1 ? MAXPATHLEN - 1 : strlen(filepath);
778-
real_path = estrndup(filepath, copy_len);
778+
if (real_path) {
779+
memcpy(real_path, filepath, copy_len);
780+
real_path[copy_len] = '\0';
781+
} else {
782+
real_path = estrndup(filepath, copy_len);
783+
}
779784
close(fdtest);
780785
return real_path;
781786
} else {

0 commit comments

Comments
 (0)