summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/date/date_core.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 173de3c0a68..5a1bb0e01ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri May 6 16:27:33 2011 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * ext/date/date_core.c (DAY_IN_NANOSECONDS): refix: 31438.
+ check with LONG_MAX and cast as long; without this the calculation
+ will be done as int and overflow.
+
Fri May 6 15:01:11 2011 URABE Shyouhei <shyouhei@ruby-lang.org>
* ext/syck/rubyext.c (mktime_do): avoid buffer overrun, by
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index 84338c4eff8..73d0b553478 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -42,8 +42,8 @@
#define DAY_IN_SECONDS 86400
#define SECOND_IN_NANOSECONDS 1000000000
-#if (ULONG_MAX / DAY_IN_SECONDS) > SECOND_IN_NANOSECONDS
-#define DAY_IN_NANOSECONDS LONG2NUM(DAY_IN_SECONDS * SECOND_IN_NANOSECONDS)
+#if (LONG_MAX / DAY_IN_SECONDS) > SECOND_IN_NANOSECONDS
+#define DAY_IN_NANOSECONDS LONG2NUM((long)DAY_IN_SECONDS * SECOND_IN_NANOSECONDS)
#elif defined HAVE_LONG_LONG
#define DAY_IN_NANOSECONDS LL2NUM((LONG_LONG)DAY_IN_SECONDS * SECOND_IN_NANOSECONDS)
#else