OSDN Git Service

Work around tzcode's reliance on signed overflow.
authorElliott Hughes <enh@google.com>
Thu, 22 Aug 2013 18:37:32 +0000 (11:37 -0700)
committerElliott Hughes <enh@google.com>
Thu, 22 Aug 2013 19:23:47 +0000 (12:23 -0700)
I've mailed the tz list about this, and will switch to whatever upstream
fix comes along as soon as it's available.

Bug: 10310929

(cherry picked from commit 7843d44a594270bcb56e98b130603c054f8a9d38)

Change-Id: I205e2440703444c50cecd91d3458d33613ddbc59

libc/Android.mk
tests/time_test.cpp

index 9610c14..cc2e0e9 100644 (file)
@@ -718,6 +718,8 @@ LOCAL_CFLAGS := \
     -DTZDIR=\"/system/usr/share/zoneinfo\" \
     -DTM_GMTOFF=tm_gmtoff \
     -DUSG_COMPAT=1
+# tzcode currently relies on signed overflow in numerous places (http://b/10310929).
+LOCAL_CFLAGS += -fno-strict-overflow
 LOCAL_C_INCLUDES := $(libc_common_c_includes)
 LOCAL_MODULE := libc_tzcode
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
index 0ad4763..02163a5 100644 (file)
@@ -54,3 +54,16 @@ TEST(time, gmtime) {
   ASSERT_EQ(0, broken_down->tm_mon);
   ASSERT_EQ(1970, broken_down->tm_year + 1900);
 }
+
+#ifdef __BIONIC__
+TEST(time, mktime_10310929) {
+  struct tm t;
+  memset(&t, 0, sizeof(tm));
+  t.tm_year = 200;
+  t.tm_mon = 2;
+  t.tm_mday = 10;
+
+  ASSERT_EQ(-1, mktime(&t));
+  ASSERT_EQ(-1, mktime_tz(&t, "UTC"));
+}
+#endif