integer overflow yields incorrect results and buffer overflow on 64-bit machines

Patrick Pelissier patrick.pelissier at gmail.com
Mon Feb 25 21:11:59 CET 2008


>  Unfortunately, changing the _mp_size and _mp_alloc fields to long
>  cannot be done without breaking compatibility (the size of the type
>  should not change).
>
>  I am pondering some hairy solutions for GMP 5, stealing bits from the
>  _mp_alloc field for use in the _mp_size field, and letting the
>  remaining _mp_alloc bits be coded as a little home-brew floating point
>  number.

 Don't forget that gmp.h defines many macro functions which access
_mp_size field directly:
mpz_abs / mpz_fits_uint_p / mpz_get_ui / ...

 You can't avoid breaking binary compatibility for GMP 5, I think.

--
 Sincerely,
  Patrick Pelissier


More information about the gmp-bugs mailing list