From: Corinna Vinschen Date: Wed, 12 Nov 2014 09:10:22 +0000 (+0000) Subject: * libc/stdlib/strtod.c (sulp): Cast to int32_t to avoid overflow. X-Git-Tag: cygwin-1_7_33-release~1 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=3dce84ad075142822bd777ffd80e707ec2e9780d;p=newlib-cygwin.git * 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. --- diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 31c56ffe8..a79fd4783 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,9 @@ +2014-11-12 Jon Beniston + + * 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 * libc/machine/aarch64/strcpy.S: New file. diff --git a/newlib/libc/stdlib/strtod.c b/newlib/libc/stdlib/strtod.c index f7cae78f7..9b064f4a8 100644 --- a/newlib/libc/stdlib/strtod.c +++ b/newlib/libc/stdlib/strtod.c @@ -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 diff --git a/newlib/libc/time/gmtime_r.c b/newlib/libc/time/gmtime_r.c index 8944845b0..dddd5763a 100644 --- a/newlib/libc/time/gmtime_r.c +++ b/newlib/libc/time/gmtime_r.c @@ -14,10 +14,10 @@ #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)