Bug#247848: tetex-bin: xdvi: large numerical prefixes lead to integer overflow
Matt Swift <swift@alum.mit.edu> writes:
> In any case, I don't have the full fix, but I have a fix in
> pseudocode, if someone else figures out how to define the portable C
> MAXINT magical constant.
> (Hi Stefan -- yes, this problem is still there in xdvi 22.82.1-cvs1.
> The code from the Debian version quoted below is only slightly
> different: no "static" number and no #if TOOLKIT. I submit the bug to
> Debian because I hope a Debian person can supply the part I don't know
> how to write and submit a real patch upstream.)
Thanks very much for the suggestions; I've added them to the
xdvik CVS (xdvik-22.83-CVS2).
> if ( (number < MAXINT_QUOT) || \
> ((number == MAXINT_QUOT) && (digit <= MAXINT_MOD)) ) {
> number = number * 10 + digit;
> }
> else {
> number = MAXINT; /* maybe not wise because not what the user requested */
> WARNING_NUMBER_HAS_GOTTEN_TOO_LARGE();
here I went for giving a warning and not changing the current value.
> }
> I have not checked the above code carefully for off-by-one errors at
> boundary conditions!
looks OK to me ;-)
Best,
Stefan
Reply to: