]> granicus.if.org Git - php/commitdiff
- Fixed bug #49585 (date_format buffer not long enough for >4 digit years).
authorPierre Joye <pajoye@php.net>
Thu, 11 Feb 2010 11:02:53 +0000 (11:02 +0000)
committerPierre Joye <pajoye@php.net>
Thu, 11 Feb 2010 11:02:53 +0000 (11:02 +0000)
NEWS
ext/date/php_date.c
ext/date/tests/bug49585.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 90d3daa456cda34dce7a9a47ab80e038a5e7e8cb..2d8ac68634273a08a8e4127e73b8563b6a97c254 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,8 @@ PHP                                                                        NEWS
 
 - Fixed bug #50940 Custom content-length set incorrectly in Apache sapis. 
   (Brian France, Rasmus)
+- Fixed bug #50930 (Wrong date by php_date.c patch with ancient gcc/glibc
+  versions). (Derick)
 - Fixed bug #50907 (X-PHP-Originating-Script adding two new lines in *NIX).
   (Ilia)
 - Fixed bug #50859 (build fails with openssl 1.0 due to md2 deprecation).   
@@ -49,6 +51,8 @@ PHP                                                                        NEWS
 - Fixed bug #50632 (filter_input() does not return default value if the
   variable does not exist). (Ilia)
 - Fixed bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect). (Pierrick)
+- Fixed bug #49585 (date_format buffer not long enough for >4 digit years).
+  (Derick, Adam)
 - Fixed bug #49560 (oci8: using LOBs causes slow PHP shutdown). (Oracle Corp.)
 - Fixed bug #48590 (SoapClient does not honor max_redirects). (Sriram)
 - Fixed bug #48190 (Content-type parameter "boundary" is not case-insensitive
index 3df42fac7345a57bba6b90b1eb181cd99954e766..8e4ef4fa90f52932ed4e5f86da398d6ede29fbee 100644 (file)
@@ -1126,7 +1126,7 @@ static char *date_format(char *format, int format_len, timelib_time *t, int loca
                        case 'Z': length = slprintf(buffer, 32, "%d", localtime ? offset->offset : 0); break;
 
                        /* full date/time */
-                       case 'c': length = slprintf(buffer, 32, "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d",
+                       case 'c': length = slprintf(buffer, 96, "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d",
                                                                        (int) t->y, (int) t->m, (int) t->d,
                                                                                        (int) t->h, (int) t->i, (int) t->s,
                                                                                        localtime ? ((offset->offset < 0) ? '-' : '+') : '+',
diff --git a/ext/date/tests/bug49585.phpt b/ext/date/tests/bug49585.phpt
new file mode 100644 (file)
index 0000000..2ec1424
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Bug #49585 (date_format buffer not long enough for >4 digit years)
+--FILE--
+<?php
+date_default_timezone_set('UTC');
+
+$date = new DateTime('-1500-01-01');
+var_dump($date->format('r'));
+
+$date->setDate(-2147483648, 1, 1);
+var_dump($date->format('r'));
+var_dump($date->format('c'));
+--EXPECT--
+string(32) "Sat, 01 Jan -1500 00:00:00 +0000"
+string(42) "Unknown, 01 Jan -2147483648 00:00:00 +0000"
+string(32) "-2147483648-01-01T00:00:00+00:00"