]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Avoid signed shift overflow in pow (bug 21309).
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Tue, 19 Dec 2017 18:41:01 +0000 (18:41 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 19 Dec 2017 18:41:01 +0000 (18:41 +0000)
As noted in bug 21309, dbl-64/e_pow.c contains signed int shifts that,
although the shift count is in the range [0, 31], shift bits into and
beyond the sign bit and so are undefined in ISO C.  Although this is
defined in GNU C, this patch from the bug cleans up the code to avoid
those shifts.

Tested for x86_64.

[BZ #21309]
* sysdeps/ieee754/dbl-64/e_pow.c (checkint): Make m and n
unsigned.

ChangeLog
sysdeps/ieee754/dbl-64/e_pow.c

index 4f836e3f675cec00eaffede0f77c66e9b97c2bd3..d194a7359283777b883447504ed42e2dfce5f8a1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-12-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       [BZ #21309]
+       * sysdeps/ieee754/dbl-64/e_pow.c (checkint): Make m and n
+       unsigned.
+
 2017-12-19  Joseph Myers  <joseph@codesourcery.com>
 
        Revert:
index 9f6439ee42a8970c40a0373d2eeee00f6aaadf69..8c7fb74549e50c8e88f86b52a2c68bc4d42b6675 100644 (file)
@@ -452,7 +452,8 @@ checkint (double x)
     int4 i[2];
     double x;
   } u;
-  int k, m, n;
+  int k;
+  unsigned int m, n;
   u.x = x;
   m = u.i[HIGH_HALF] & 0x7fffffff;     /* no sign */
   if (m >= 0x7ff00000)