"(unsigned long)(x * y)" will multiply ints x and y into a new int, then converts the int into an unsigned long. Replace it with "(unsigned long)(x) * (unsigned long)(y)" which performs the multiplication in a larger space.
Patch attached. Nick
diff -r d300ea27b301 mpn/generic/get_d.c
--- a/mpn/generic/get_d.c Wed Feb 08 09:38:28 2017 +0100
+++ b/mpn/generic/get_d.c Thu Feb 09 15:22:07 2017 -0800
@@ -144,8 +144,8 @@
/* Adjust exp to a radix point just above {up,size}, guarding against
overflow. After this exp can of course be reduced to anywhere within
the {up,size} region without underflow. */
- if (UNLIKELY ((unsigned long) (GMP_NUMB_BITS * size)
- > ((unsigned long) LONG_MAX - exp)))
+ if (UNLIKELY ((unsigned long) (GMP_NUMB_BITS) * (unsigned long) (size)
+ > ((unsigned long) LONG_MAX - (unsigned long) exp)))
{
#if _GMP_IEEE_FLOATS
goto ieee_infinity;
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ gmp-bugs mailing list [email protected] https://gmplib.org/mailman/listinfo/gmp-bugs
