* 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.
This commit is contained in:
Corinna Vinschen 2014-11-12 09:10:22 +00:00
parent 9de862718c
commit 3dce84ad07
3 changed files with 11 additions and 5 deletions

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

View 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

View File

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