components/mpfr/patches/002-CVE-2014-9474-strtofr.c.patch
author Stefan Teleman <stefan.teleman@oracle.com>
Wed, 28 Jan 2015 11:07:54 -0800
branchs11-update
changeset 3698 9c01a3410e89
permissions -rw-r--r--
20300662 problem in LIBRARY/LIBMPFR
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3698
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     1
# Original patch for libmpfr 3.1.2 is here:
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     2
# http://www.mpfr.org/mpfr-3.1.2/patch11
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     3
# Backported to libmpfr 2.4.2.
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     4
--- strtofr.c	2009-11-29 18:43:08.000000000 -0800
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     5
+++ strtofr.c	2015-01-23 11:30:29.242406530 -0800
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     6
@@ -464,8 +464,10 @@
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     7
       /* prec bits corresponds to ysize limbs */
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     8
       ysize_bits = ysize * BITS_PER_MP_LIMB;
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     9
       /* and to ysize_bits >= prec > MPFR_PREC (x) bits */
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    10
-      y = (mp_limb_t*) MPFR_TMP_ALLOC ((2 * ysize + 1) * sizeof (mp_limb_t));
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    11
-      y += ysize; /* y has (ysize+1) allocated limbs */
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    12
+      /* we need to allocate one more limb to work around
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    13
+       * https://gmplib.org/list-archives/gmp-bugs/2013-December/003267.html */
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    14
+      y = (mp_limb_t*) MPFR_TMP_ALLOC ((2 * ysize + 2) * sizeof (mp_limb_t));
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    15
+      y += ysize; /* y has (ysize+2) allocated limbs */
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    16
 
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    17
       /* pstr_size is the number of characters we read in pstr->mant
9c01a3410e89 20300662 problem in LIBRARY/LIBMPFR
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    18
          to have at least ysize full limbs.