out-of-bound write

Vincent Lefevre vincent at vinc17.net
Tue Dec 17 14:43:15 UTC 2013

On 2013-12-17 15:15:54 +0100, Torbjorn Granlund wrote:
> Vincent Lefevre <vincent at vinc17.net> writes:
>   So, if I understand correctly, you consider that the current
>   documentation is incorrect and GMP's current behavior is the
>   expected one.
> I suggest that we documentat the current behavior.
> But I mean to invite discussion.
> Note that the space requirements are only partially documented: If the
> string has >= 1 leading zero, some unspecified amount of space is
> needed.

Indeed. This is more or less equivalent to saying that this case
has undefined behavior. Either leading zeros should be forbidden,
or a bound on the amount of space should be documented. IMHO, for
a fixed string size (and fixed base), the documented bound should
be an increasing function of the value. For instance, it could be
documented that the size in the case of leading zeros is bounded
by the 1 + exact size of B^(STRSIZE-1). Is this the case with the
current code?

Vincent Lefèvre <vincent at vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

More information about the gmp-bugs mailing list