derick Wed, 10 Feb 2010 16:55:40 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=294855
Log: - Fixed bug #49585 (date_format buffer not long enough for >4 digit years). #- Was already partly fixed with my previous commit. Bug: http://bugs.php.net/49585 (Assigned) date_format buffer not long enough for >4 digit years Changed paths: U php/php-src/branches/PHP_5_2/NEWS U php/php-src/branches/PHP_5_2/ext/date/php_date.c A php/php-src/branches/PHP_5_2/ext/date/tests/bug49585.phpt U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/date/php_date.c A php/php-src/branches/PHP_5_3/ext/date/tests/bug49585.phpt A php/php-src/trunk/ext/date/tests/bug49585.phpt Modified: php/php-src/branches/PHP_5_2/NEWS =================================================================== --- php/php-src/branches/PHP_5_2/NEWS 2010-02-10 16:23:30 UTC (rev 294854) +++ php/php-src/branches/PHP_5_2/NEWS 2010-02-10 16:55:40 UTC (rev 294855) @@ -7,10 +7,14 @@ - 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) Modified: php/php-src/branches/PHP_5_2/ext/date/php_date.c =================================================================== --- php/php-src/branches/PHP_5_2/ext/date/php_date.c 2010-02-10 16:23:30 UTC (rev 294854) +++ php/php-src/branches/PHP_5_2/ext/date/php_date.c 2010-02-10 16:55:40 UTC (rev 294855) @@ -863,7 +863,7 @@ 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) ? '-' : '+') : '+', Added: php/php-src/branches/PHP_5_2/ext/date/tests/bug49585.phpt =================================================================== --- php/php-src/branches/PHP_5_2/ext/date/tests/bug49585.phpt (rev 0) +++ php/php-src/branches/PHP_5_2/ext/date/tests/bug49585.phpt 2010-02-10 16:55:40 UTC (rev 294855) @@ -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" Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2010-02-10 16:23:30 UTC (rev 294854) +++ php/php-src/branches/PHP_5_3/NEWS 2010-02-10 16:55:40 UTC (rev 294855) @@ -27,6 +27,8 @@ (Jani) - 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). @@ -59,6 +61,8 @@ - Fixed bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect). (Pierrick) - Fixed bug #50416 (PROCEDURE db.myproc can't return a result set in the given context). (Andrey) +- 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 #49463 (setAttributeNS fails setting default namespace). (Rob) - Fixed bug #48811 (Directives in PATH section do not get applied to Modified: php/php-src/branches/PHP_5_3/ext/date/php_date.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/date/php_date.c 2010-02-10 16:23:30 UTC (rev 294854) +++ php/php-src/branches/PHP_5_3/ext/date/php_date.c 2010-02-10 16:55:40 UTC (rev 294855) @@ -1120,7 +1120,7 @@ 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) ? '-' : '+') : '+', Added: php/php-src/branches/PHP_5_3/ext/date/tests/bug49585.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/date/tests/bug49585.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/date/tests/bug49585.phpt 2010-02-10 16:55:40 UTC (rev 294855) @@ -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" Added: php/php-src/trunk/ext/date/tests/bug49585.phpt =================================================================== --- php/php-src/trunk/ext/date/tests/bug49585.phpt (rev 0) +++ php/php-src/trunk/ext/date/tests/bug49585.phpt 2010-02-10 16:55:40 UTC (rev 294855) @@ -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-- +unicode(32) "Sat, 01 Jan -1500 00:00:00 +0000" +unicode(42) "Unknown, 01 Jan -2147483648 00:00:00 +0000" +unicode(32) "-2147483648-01-01T00:00:00+00:00"
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php