]> granicus.if.org Git - php/commitdiff
- Fixed bug #49585 (date_format buffer not long enough for >4 digit years).
authorDerick Rethans <derick@php.net>
Wed, 10 Feb 2010 16:55:40 +0000 (16:55 +0000)
committerDerick Rethans <derick@php.net>
Wed, 10 Feb 2010 16:55:40 +0000 (16:55 +0000)
#- Was already partly fixed with my previous commit.

NEWS
ext/date/php_date.c
ext/date/tests/bug49585.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 1f8aa5b1e588958bbf0c58fa66e45b58265d8009..536fb986695542e0b44d399d72bea469e4162c1c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,10 +7,14 @@ 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 #50847 (strip_tags() removes all tags greater then 1023 bytes
   long). (Ilia)
 - Fixed bug #50727 (Accessing mysqli->affected_rows on no connection causes
   segfault). (Andrey, Johannes)
+- Fixed bug #49585 (date_format buffer not long enough for >4 digit years).
+  (Derick, Adam)
 - Fixed bug #48667 (Implementing Iterator and IteratorAggregate). (Etienne)
 - Fixed bug #47601 (defined() requires class to exist when testing for class
   constants). (Ilia)
index 647e2710157944ca6455e6a9ebabce04ba0f2338..5803ad05e79694276465843c70c3cdf2892eae9a 100644 (file)
@@ -863,7 +863,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"