Fix time.mktime_EOVERFLOW for LP32.

Times before 1901-12-13 *underflow* on LP32, making the year 1900 a bad
choice for success case.

Bug: http://b/31305222
Change-Id: I20d4885c80b57707225580db044abc8948a55fdc
This commit is contained in:
Elliott Hughes 2016-09-06 13:25:53 -07:00
parent 85b15b1d0b
commit 47126edb90
1 changed files with 7 additions and 1 deletions

View File

@ -124,7 +124,10 @@ TEST(time, mktime_10310929) {
TEST(time, mktime_EOVERFLOW) {
struct tm t;
memset(&t, 0, sizeof(tm));
t.tm_year = 0;
// LP32 year range is 1901-2038, so this year is guaranteed not to overflow.
t.tm_year = 2016 - 1900;
t.tm_mon = 2;
t.tm_mday = 10;
@ -132,7 +135,10 @@ TEST(time, mktime_EOVERFLOW) {
ASSERT_NE(static_cast<time_t>(-1), mktime(&t));
ASSERT_EQ(0, errno);
// This will overflow for LP32 or LP64.
t.tm_year = INT_MAX;
errno = 0;
ASSERT_EQ(static_cast<time_t>(-1), mktime(&t));
ASSERT_EQ(EOVERFLOW, errno);
}