|
|
4b401f |
From 88412772d295ebf7dd34409534507dc9bcac726e Mon Sep 17 00:00:00 2001
|
|
|
4b401f |
From: Stanislav Malyshev <stas@php.net>
|
|
|
4b401f |
Date: Sun, 28 Sep 2014 17:33:44 -0700
|
|
|
4b401f |
Subject: [PATCH] Fix bug #68027 - fix date parsing in XMLRPC lib
|
|
|
4b401f |
|
|
|
4b401f |
---
|
|
|
4b401f |
NEWS | 5 ++++-
|
|
|
4b401f |
ext/xmlrpc/libxmlrpc/xmlrpc.c | 13 ++++++++-----
|
|
|
4b401f |
ext/xmlrpc/tests/bug68027.phpt | 44 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
4b401f |
3 files changed, 56 insertions(+), 6 deletions(-)
|
|
|
4b401f |
create mode 100644 ext/xmlrpc/tests/bug68027.phpt
|
|
|
4b401f |
|
|
|
4b401f |
diff --git a/ext/xmlrpc/libxmlrpc/xmlrpc.c b/ext/xmlrpc/libxmlrpc/xmlrpc.c
|
|
|
4b401f |
index ce70c2a..b766a54 100644
|
|
|
4b401f |
--- a/ext/xmlrpc/libxmlrpc/xmlrpc.c
|
|
|
4b401f |
+++ b/ext/xmlrpc/libxmlrpc/xmlrpc.c
|
|
|
4b401f |
@@ -219,16 +219,19 @@ static int date_from_ISO8601 (const char *text, time_t * value) {
|
|
|
4b401f |
n = 10;
|
|
|
4b401f |
tm.tm_mon = 0;
|
|
|
4b401f |
for(i = 0; i < 2; i++) {
|
|
|
4b401f |
- XMLRPC_IS_NUMBER(text[i])
|
|
|
4b401f |
+ XMLRPC_IS_NUMBER(text[i+4])
|
|
|
4b401f |
tm.tm_mon += (text[i+4]-'0')*n;
|
|
|
4b401f |
n /= 10;
|
|
|
4b401f |
}
|
|
|
4b401f |
tm.tm_mon --;
|
|
|
4b401f |
+ if(tm.tm_mon < 0 || tm.tm_mon > 11) {
|
|
|
4b401f |
+ return -1;
|
|
|
4b401f |
+ }
|
|
|
4b401f |
|
|
|
4b401f |
n = 10;
|
|
|
4b401f |
tm.tm_mday = 0;
|
|
|
4b401f |
for(i = 0; i < 2; i++) {
|
|
|
4b401f |
- XMLRPC_IS_NUMBER(text[i])
|
|
|
4b401f |
+ XMLRPC_IS_NUMBER(text[i+6])
|
|
|
4b401f |
tm.tm_mday += (text[i+6]-'0')*n;
|
|
|
4b401f |
n /= 10;
|
|
|
4b401f |
}
|
|
|
4b401f |
@@ -236,7 +239,7 @@ static int date_from_ISO8601 (const char *text, time_t * value) {
|
|
|
4b401f |
n = 10;
|
|
|
4b401f |
tm.tm_hour = 0;
|
|
|
4b401f |
for(i = 0; i < 2; i++) {
|
|
|
4b401f |
- XMLRPC_IS_NUMBER(text[i])
|
|
|
4b401f |
+ XMLRPC_IS_NUMBER(text[i+9])
|
|
|
4b401f |
tm.tm_hour += (text[i+9]-'0')*n;
|
|
|
4b401f |
n /= 10;
|
|
|
4b401f |
}
|
|
|
4b401f |
@@ -244,7 +247,7 @@ static int date_from_ISO8601 (const char *text, time_t * value) {
|
|
|
4b401f |
n = 10;
|
|
|
4b401f |
tm.tm_min = 0;
|
|
|
4b401f |
for(i = 0; i < 2; i++) {
|
|
|
4b401f |
- XMLRPC_IS_NUMBER(text[i])
|
|
|
4b401f |
+ XMLRPC_IS_NUMBER(text[i+12])
|
|
|
4b401f |
tm.tm_min += (text[i+12]-'0')*n;
|
|
|
4b401f |
n /= 10;
|
|
|
4b401f |
}
|
|
|
4b401f |
@@ -252,7 +255,7 @@ static int date_from_ISO8601 (const char *text, time_t * value) {
|
|
|
4b401f |
n = 10;
|
|
|
4b401f |
tm.tm_sec = 0;
|
|
|
4b401f |
for(i = 0; i < 2; i++) {
|
|
|
4b401f |
- XMLRPC_IS_NUMBER(text[i])
|
|
|
4b401f |
+ XMLRPC_IS_NUMBER(text[i+15])
|
|
|
4b401f |
tm.tm_sec += (text[i+15]-'0')*n;
|
|
|
4b401f |
n /= 10;
|
|
|
4b401f |
}
|
|
|
4b401f |
diff --git a/ext/xmlrpc/tests/bug68027.phpt b/ext/xmlrpc/tests/bug68027.phpt
|
|
|
4b401f |
new file mode 100644
|
|
|
4b401f |
index 0000000..a5c96f1
|
|
|
4b401f |
--- /dev/null
|
|
|
4b401f |
+++ b/ext/xmlrpc/tests/bug68027.phpt
|
|
|
4b401f |
@@ -0,0 +1,44 @@
|
|
|
4b401f |
+--TEST--
|
|
|
4b401f |
+Bug #68027 (buffer overflow in mkgmtime() function)
|
|
|
4b401f |
+--SKIPIF--
|
|
|
4b401f |
+
|
|
|
4b401f |
+if (!extension_loaded("xmlrpc")) print "skip";
|
|
|
4b401f |
+?>
|
|
|
4b401f |
+--FILE--
|
|
|
4b401f |
+
|
|
|
4b401f |
+
|
|
|
4b401f |
+$d = '6-01-01 20:00:00';
|
|
|
4b401f |
+xmlrpc_set_type($d, 'datetime');
|
|
|
4b401f |
+var_dump($d);
|
|
|
4b401f |
+$datetime = "2001-0-08T21:46:40-0400";
|
|
|
4b401f |
+$obj = xmlrpc_decode("<methodResponse><params><param><value><dateTime.iso8601>$datetime</dateTime.iso8601></value></param></params></methodResponse>");
|
|
|
4b401f |
+print_r($obj);
|
|
|
4b401f |
+
|
|
|
4b401f |
+$datetime = "34770-0-08T21:46:40-0400";
|
|
|
4b401f |
+$obj = xmlrpc_decode("<methodResponse><params><param><value><dateTime.iso8601>$datetime</dateTime.iso8601></value></param></params></methodResponse>");
|
|
|
4b401f |
+print_r($obj);
|
|
|
4b401f |
+
|
|
|
4b401f |
+echo "Done\n";
|
|
|
4b401f |
+?>
|
|
|
4b401f |
+--EXPECTF--
|
|
|
4b401f |
+object(stdClass)#1 (3) {
|
|
|
4b401f |
+ ["scalar"]=>
|
|
|
4b401f |
+ string(16) "6-01-01 20:00:00"
|
|
|
4b401f |
+ ["xmlrpc_type"]=>
|
|
|
4b401f |
+ string(8) "datetime"
|
|
|
4b401f |
+ ["timestamp"]=>
|
|
|
4b401f |
+ int(%d)
|
|
|
4b401f |
+}
|
|
|
4b401f |
+stdClass Object
|
|
|
4b401f |
+(
|
|
|
4b401f |
+ [scalar] => 2001-0-08T21:46:40-0400
|
|
|
4b401f |
+ [xmlrpc_type] => datetime
|
|
|
4b401f |
+ [timestamp] => %s
|
|
|
4b401f |
+)
|
|
|
4b401f |
+stdClass Object
|
|
|
4b401f |
+(
|
|
|
4b401f |
+ [scalar] => 34770-0-08T21:46:40-0400
|
|
|
4b401f |
+ [xmlrpc_type] => datetime
|
|
|
4b401f |
+ [timestamp] => %d
|
|
|
4b401f |
+)
|
|
|
4b401f |
+Done
|
|
|
4b401f |
--
|
|
|
4b401f |
2.1.0
|
|
|
4b401f |
|