Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2014-11-12 12:10:22 +0300
committerCorinna Vinschen <corinna@vinschen.de>2014-11-12 12:10:22 +0300
commit3dce84ad075142822bd777ffd80e707ec2e9780d (patch)
treed9567bcacc9afcb87fa1105ffb1b14246e5cf01e
parent9de862718c69bc4b4bad96705b1df2b21e98fcdb (diff)
* 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.
-rw-r--r--newlib/ChangeLog6
-rw-r--r--newlib/libc/stdlib/strtod.c2
-rw-r--r--newlib/libc/time/gmtime_r.c8
3 files changed, 11 insertions, 5 deletions
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 <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.
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)