[Gmp-commit] /var/hg/gmp-6.1: 3 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Mon Dec 14 07:34:43 UTC 2015


details:   /var/hg/gmp-6.1/rev/ce35b7eca913
changeset: 16929:ce35b7eca913
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Mon Dec 14 08:29:18 2015 +0100
description:
printf/doprnt.c: Avoid buffer overrun with long long limbs.

details:   /var/hg/gmp-6.1/rev/ec5e9ce0336d
changeset: 16930:ec5e9ce0336d
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Mon Dec 14 08:32:18 2015 +0100
description:
gmp-impl.h (MPN_TOOM22_MUL_MINSIZE): Consider ToomX2 limits.

details:   /var/hg/gmp-6.1/rev/fff644d85371
changeset: 16931:fff644d85371
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Mon Dec 14 08:33:53 2015 +0100
description:
tests/mpn/t-toom22.c: Keep on testing small sizes.

diffstat:

 gmp-impl.h           |  4 +++-
 printf/doprnt.c      |  6 +++---
 tests/mpn/t-toom22.c |  2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diffs (55 lines):

diff -r e1db5890f78d -r fff644d85371 gmp-impl.h
--- a/gmp-impl.h	Mon Nov 23 17:39:14 2015 +0100
+++ b/gmp-impl.h	Mon Dec 14 08:33:53 2015 +0100
@@ -1273,7 +1273,9 @@
 #endif
 #define BELOW_THRESHOLD(size,thresh)  (! ABOVE_THRESHOLD (size, thresh))
 
-#define MPN_TOOM22_MUL_MINSIZE    4
+/* The minimal supported value for Toom22 depends also on Toom32 and
+   Toom42 implementations. */
+#define MPN_TOOM22_MUL_MINSIZE    6
 #define MPN_TOOM2_SQR_MINSIZE     4
 
 #define MPN_TOOM33_MUL_MINSIZE   17
diff -r e1db5890f78d -r fff644d85371 printf/doprnt.c
--- a/printf/doprnt.c	Mon Nov 23 17:39:14 2015 +0100
+++ b/printf/doprnt.c	Mon Dec 14 08:33:53 2015 +0100
@@ -160,7 +160,7 @@
 	      const char *orig_fmt, va_list orig_ap)
 {
   va_list  ap, this_ap, last_ap;
-  size_t   alloc_fmt_size;
+  size_t   alloc_fmt_size, orig_fmt_size;
   char     *fmt, *alloc_fmt, *last_fmt, *this_fmt, *gmp_str;
   int      retval = 0;
   int      type, fchar, *value, seen_precision;
@@ -180,7 +180,7 @@
      piece can be null-terminated.  We're not going to be very fast here, so
      use __gmp_allocate_func rather than TMP_ALLOC, to avoid overflowing the
      stack if a long output string is given.  */
-  alloc_fmt_size = strlen (orig_fmt) + 1;
+  alloc_fmt_size = orig_fmt_size = strlen (orig_fmt) + 1;
 #if _LONG_LONG_LIMB
   /* for a long long limb we change %Mx to %llx, so could need an extra 1
      char for every 3 existing */
@@ -188,7 +188,7 @@
 #endif
   alloc_fmt = __GMP_ALLOCATE_FUNC_TYPE (alloc_fmt_size, char);
   fmt = alloc_fmt;
-  memcpy (fmt, orig_fmt, alloc_fmt_size);
+  memcpy (fmt, orig_fmt, orig_fmt_size);
 
   /* last_fmt and last_ap are just after the last output, and hence where
      the next output will begin, when that's done */
diff -r e1db5890f78d -r fff644d85371 tests/mpn/t-toom22.c
--- a/tests/mpn/t-toom22.c	Mon Nov 23 17:39:14 2015 +0100
+++ b/tests/mpn/t-toom22.c	Mon Dec 14 08:33:53 2015 +0100
@@ -1,6 +1,6 @@
 #define mpn_toomMN_mul mpn_toom22_mul
 #define mpn_toomMN_mul_itch mpn_toom22_mul_itch
-#define MIN_AN MPN_TOOM22_MUL_MINSIZE
+#define MIN_AN MIN(MPN_TOOM22_MUL_MINSIZE,4)
 
 #define MIN_BN(an)				\
   ((an) >= 2*MUL_TOOM22_THRESHOLD		\


More information about the gmp-commit mailing list