* 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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2011-05-06 08:38:36 +00:00
parent 534388dd17
commit 1f6a7c18f5
2 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -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