[Patches] Fix for bug PR#341
M.-A. Lemburg
mal@lemburg.com
Mon, 29 May 2000 09:44:37 +0200
Tim Peters wrote:
>
> [MAL's Fix to avoid buffer overruns in %-formatting of integers]
>
> [Fred]
> > I've not read the files you're patching for this one, but is
> > this really the right patch? How did you come up with 50?
>
> [MAL]
> > Simple: the code for the float formatting uses the same
> > limit and I find it reasonably high to not cause any
> > harm to existing programs.
>
> [Fred]
> > I'm also not comfortable with the magic numbers in the source.
>
> [MAL]
> > Well, the limits seem arbitrary, but then: who will want
> > to print integers with more than 40 digits (2^128 + sign) ?
>
> I can't object to the patch, but I'll join Fred in objecting to the code
> it's mimicking: not only do magic numbers suck, but these particular magic
> numbers implicitly rely on PyString_Format's tmpbuf vector being declared of
> another magical size larger than them. As usual, flaky code gets flakier.
Agreed... just thought that it's better to solve this problem
fast than to go and redesign the formatting code altogether.
A redesign would, of course, use a malloced buffer, the n-variants
of printf() and add long support ;-) ... maybe for 1.7.
--
Marc-Andre Lemburg
______________________________________________________________________
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/