summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/date/lib/parse_date.c2
-rw-r--r--ext/date/lib/parse_date.re2
-rw-r--r--ext/date/tests/bug64157.phpt14
-rw-r--r--ext/filter/logical_filters.c5
-rw-r--r--ext/filter/tests/018.phpt4
-rw-r--r--ext/filter/tests/bug64441.phpt11
-rw-r--r--main/fopen_wrappers.c7
7 files changed, 38 insertions, 7 deletions
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c
index 9428ce3804..0e99e231d6 100644
--- a/ext/date/lib/parse_date.c
+++ b/ext/date/lib/parse_date.c
@@ -25002,7 +25002,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
TIMELIB_CHECK_NUMBER;
sec = timelib_get_nr_ex((char **) &ptr, 2, &length);
if (sec == TIMELIB_UNSET || length != 2) {
- add_pbf_error(s, "A two second minute could not be found", string, begin);
+ add_pbf_error(s, "A two digit second could not be found", string, begin);
} else {
s->time->s = sec;
}
diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re
index 7efeb430c3..6d91d9ada9 100644
--- a/ext/date/lib/parse_date.re
+++ b/ext/date/lib/parse_date.re
@@ -2009,7 +2009,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
TIMELIB_CHECK_NUMBER;
sec = timelib_get_nr_ex((char **) &ptr, 2, &length);
if (sec == TIMELIB_UNSET || length != 2) {
- add_pbf_error(s, "A two second minute could not be found", string, begin);
+ add_pbf_error(s, "A two digit second could not be found", string, begin);
} else {
s->time->s = sec;
}
diff --git a/ext/date/tests/bug64157.phpt b/ext/date/tests/bug64157.phpt
new file mode 100644
index 0000000000..fb71495430
--- /dev/null
+++ b/ext/date/tests/bug64157.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Test for bug #64157: DateTime::createFromFormat() reports confusing error message
+--CREDITS--
+Boro Sitnikovski <buritomath@yahoo.com>
+--INI--
+date.timezone = UTC
+--FILE--
+<?php
+DateTime::createFromFormat('s', '0');
+$lastErrors = DateTime::getLastErrors();
+print_r($lastErrors['errors'][0]);
+?>
+--EXPECT--
+A two digit second could not be found
diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c
index b8df2183b9..653cce23e6 100644
--- a/ext/filter/logical_filters.c
+++ b/ext/filter/logical_filters.c
@@ -484,10 +484,6 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
}
s++;
}
-
- if (*(e - 1) == '.') {
- goto bad_url;
- }
}
if (
@@ -718,6 +714,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
if (flags & FILTER_FLAG_NO_RES_RANGE) {
if (
(ip[0] == 0) ||
+ (ip[0] == 100 && (ip[1] >= 64 || ip[1] <= 127)) ||
(ip[0] == 128 && ip[1] == 0) ||
(ip[0] == 191 && ip[1] == 255) ||
(ip[0] == 169 && ip[1] == 254) ||
diff --git a/ext/filter/tests/018.phpt b/ext/filter/tests/018.phpt
index af52b2e60d..9c73fc3cfc 100644
--- a/ext/filter/tests/018.phpt
+++ b/ext/filter/tests/018.phpt
@@ -15,6 +15,8 @@ var_dump(filter_var("192.168.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE
var_dump(filter_var("192.0.34.166", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE));
var_dump(filter_var("127.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
var_dump(filter_var("192.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
+var_dump(filter_var("100.0.0.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
+var_dump(filter_var("100.127.255.255", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
var_dump(filter_var("192.0.34.166", FILTER_VALIDATE_IP));
var_dump(filter_var("256.1237.123.1", FILTER_VALIDATE_IP));
var_dump(filter_var("255.255.255.255", FILTER_VALIDATE_IP));
@@ -40,6 +42,8 @@ bool(false)
string(12) "192.0.34.166"
bool(false)
string(9) "192.0.0.1"
+bool(false)
+bool(false)
string(12) "192.0.34.166"
bool(false)
string(15) "255.255.255.255"
diff --git a/ext/filter/tests/bug64441.phpt b/ext/filter/tests/bug64441.phpt
new file mode 100644
index 0000000000..149079ec05
--- /dev/null
+++ b/ext/filter/tests/bug64441.phpt
@@ -0,0 +1,11 @@
+--TEST--
+bug 64441, FILTER_VALIDATE_URL will invalidate a hostname that ended by dot
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(filter_var('http://example.com./', FILTER_VALIDATE_URL));
+var_dump(filter_var('http://example.com/', FILTER_VALIDATE_URL));
+--EXPECT--
+string(20) "http://example.com./"
+string(19) "http://example.com/"
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 6f11cf3f32..9b8645a061 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -775,7 +775,12 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co
* we cannot cannot getcwd() and the requested,
* relatively referenced file is accessible */
copy_len = strlen(filepath) > MAXPATHLEN - 1 ? MAXPATHLEN - 1 : strlen(filepath);
- real_path = estrndup(filepath, copy_len);
+ if (real_path) {
+ memcpy(real_path, filepath, copy_len);
+ real_path[copy_len] = '\0';
+ } else {
+ real_path = estrndup(filepath, copy_len);
+ }
close(fdtest);
return real_path;
} else {