Bug #75851 [NEW]: Year component overflow with formats "c" and "r"

From: Date: Sat, 20 Jan 2018 09:38:38 +0000
Subject: Bug #75851 [NEW]: Year component overflow with formats "c" and "r"
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213628@lists.php.net to get a copy of this message
From: juju2143 at gmail dot com Operating system: macOS 10.12 PHP version: 7.1.13 Package: Date/time related Bug Type: Bug Bug description:Year component overflow with formats "c" and "r" Description: ------------ I'm not sure whether PHP or even the human species will still be around when someone would want to process dates past the year 2147483647, but it seems that the format characters c, o, r, y (actually, probably everything that calculates the year except Y, L is untested) as defined in the date() manual page will compute the year component in a 32-bit integer. For consistency with Y, it might be desirable to upgrade those to 64-bit on 64-bit systems as well. Test script: --------------- echo date(DATE_ATOM."\n".DATE_RFC2822."\nc\nr\no\ny\nY\nU\n\n", PHP_INT_MIN); echo date(DATE_ATOM."\n".DATE_RFC2822."\nc\nr\no\ny\nY\nU\n\n", 67767976233532799); echo date(DATE_ATOM."\n".DATE_RFC2822."\nc\nr\no\ny\nY\nU\n\n", 67767976233532800); echo date(DATE_ATOM."\n".DATE_RFC2822."\nc\nr\no\ny\nY\nU\n\n", PHP_INT_MAX); Expected result: ---------------- -292277022657-01-27T08:29:52+00:00 Fri, 27 Jan -292277022657 08:29:52 +0000 -292277022657-01-27T08:29:52+00:00 Fri, 27 Jan -292277022657 08:29:52 +0000 -292277022657 57 (or -57?) -292277022657 -9223372036854775808 2147483647-12-31T23:59:59+00:00 Tue, 31 Dec 2147483647 23:59:59 +0000 2147483647-12-31T23:59:59+00:00 Tue, 31 Dec 2147483647 23:59:59 +0000 2147483648 47 2147483647 67767976233532799 2147483648-01-01T00:00:00+00:00 Wed, 01 Jan 2147483648 00:00:00 +0000 2147483648-01-01T00:00:00+00:00 Wed, 01 Jan 2147483648 00:00:00 +0000 2147483648 48 2147483648 67767976233532800 292277026596-12-04T15:30:07+00:00 Sun, 04 Dec 292277026596 15:30:07 +0000 292277026596-12-04T15:30:07+00:00 Sun, 04 Dec 292277026596 15:30:07 +0000 292277026596 96 292277026596 9223372036854775807 Actual result: -------------- -292277022657-01-27T08:29:52+00:00 Fri, 27 Jan -292277022657 08:29:52 +0000 -219246529-01-27T08:29:52+00:00 Fri, 27 Jan -219246529 08:29:52 +0000 -219246529 -29 -292277022657 -9223372036854775808 2147483647-12-31T23:59:59+00:00 Tue, 31 Dec 2147483647 23:59:59 +0000 2147483647-12-31T23:59:59+00:00 Tue, 31 Dec 2147483647 23:59:59 +0000 -2147483648 47 2147483647 67767976233532799 2147483648-01-01T00:00:00+00:00 Wed, 01 Jan 2147483648 00:00:00 +0000 -2147483648-01-01T00:00:00+00:00 Wed, 01 Jan -2147483648 00:00:00 +0000 -2147483648 -48 2147483648 67767976233532800 292277026596-12-04T15:30:07+00:00 Sun, 04 Dec 292277026596 15:30:07 +0000 219250468-12-04T15:30:07+00:00 Sun, 04 Dec 219250468 15:30:07 +0000 219250468 68 292277026596 9223372036854775807 -- Edit bug report at https://bugs.php.net/bug.php?id=75851&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75851&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75851&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75851&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75851&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75851&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75851&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75851&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75851&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75851&r=support Expected behavior: https://bugs.php.net/fix.php?id=75851&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75851&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75851&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75851&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75851&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75851&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75851&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75851&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75851&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75851&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75851&r=mysqlcfg

« previous php.bugs (#213628) next »