]> sourceware.org Git - newlib-cygwin.git/commitdiff
* libc/stdlib/strtod.c (sulp): Cast to int32_t to avoid overflow.
authorCorinna Vinschen <corinna@vinschen.de>
Wed, 12 Nov 2014 09:10:22 +0000 (09:10 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Wed, 12 Nov 2014 09:10:22 +0000 (09:10 +0000)
* libc/time/gmtime_r.c (DAYS_PER_*_YEARS): Convert to long constants
to avoid overflow.

newlib/ChangeLog
newlib/libc/stdlib/strtod.c
newlib/libc/time/gmtime_r.c

index 31c56ffe8ceb551737d115c95daa58f441960ad0..a79fd4783e0accc336fb187313dcd298ee6aee22 100644 (file)
@@ -1,3 +1,9 @@
+2014-11-12  Jon Beniston  <jon@beniston.com>
+
+       * libc/stdlib/strtod.c (sulp): Cast to int32_t to avoid overflow.
+       * libc/time/gmtime_r.c (DAYS_PER_*_YEARS): Convert to long constants
+       to avoid overflow.
+
 2014-11-10  Richard Earnshaw  <rearnsha@arm.com>
 
        * libc/machine/aarch64/strcpy.S: New file.
index f7cae78f76a673488c7efb239e0aacdbd02a5e4a..9b064f4a84513952743ffadfba7d7be9052b0aa0 100644 (file)
@@ -163,7 +163,7 @@ _DEFUN (sulp, (x, scale),
         rv = ulp(dval(x));
         if (!scale || (i = 2*P + 1 - ((dword0(x) & Exp_mask) >> Exp_shift)) <= 0)
                 return rv; /* Is there an example where i <= 0 ? */
-        dword0(u) = Exp_1 + (i << Exp_shift);
+        dword0(u) = Exp_1 + ((__int32_t)i << Exp_shift);
 #ifndef _DOUBLE_IS_32BITS
         dword1(u) = 0;
 #endif
index 8944845b0b1be76e6d13d27cc5106c7e575dbce6..dddd5763a4330255b20fccf2313bf368ef11c95f 100644 (file)
 
 #include "local.h"
 
-/* there are 97 leap years in 400-year periods */
-#define DAYS_PER_400_YEARS     ((400 - 97) * 365 + 97 * 366)
-/* there are 24 leap years in 100-year periods */
-#define DAYS_PER_100_YEARS     ((100 - 24) * 365 + 24 * 366)
+/* there are 97 leap years in 400-year periods. ((400 - 97) * 365 + 97 * 366) */
+#define DAYS_PER_400_YEARS     146097L
+/* there are 24 leap years in 100-year periods. ((100 - 24) * 365 + 24 * 366) */
+#define DAYS_PER_100_YEARS     36524L
 /* there is one leap year every 4 years */
 #define DAYS_PER_4_YEARS       (3 * 365 + 366)
 
This page took 0.046836 seconds and 5 git commands to generate.