bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8435: misuse of error ("...%d...", ...) on 64-bit hosts


From: Paul Eggert
Subject: bug#8435: misuse of error ("...%d...", ...) on 64-bit hosts
Date: Sat, 09 Apr 2011 11:24:08 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Thunderbird/3.1.9

On 04/09/2011 12:20 AM, Eli Zaretskii wrote:
>> Date: Fri, 08 Apr 2011 16:34:12 -0700
>> From: Paul Eggert <address@hidden>

> Then let's change doprnt to support an `int'...
> Are there any problems with this approach?

Yes: it'd be more work to do now, and will leave us with
more code to maintain afterwards.

> adding that support in other places has disadvantages that I
> mentioned in my previous message.

The disadvantages are small compared to the advantages.
Most of the changes in the patch are needed regardless
of whether doprnt is kept or discarded.  The part about
discarding doprnt shortens Emacs's code overall: it removes
283 lines (doprnt itself, plus scaffolding) and adds 17 lines
(callers adjusting to the minor differences between doprnt
and vsnprintf).  This is a clear win.

Part of the motivation here is that doprnt contains too many bugs.
I've mentioned two or three, but here's another:

                  while ('0' <= fmt[1] && fmt[1] <= '9')
                    {
                      if (n * 10 + fmt[1] - '0' < n)
                        error ("Format width or precision too large");
                      n = n * 10 + fmt[1] - '0';
                      *string++ = *++fmt;
                    }

That overflow check is clearly wrong: it will miss many
overflows.  This doprnt bug, like the others, could be fixed
by investing more time, but it's wasteful to spend time
maintaining a buggy near-copy of vsnprintf.  It's better
software engineering practice to use vsnprintf instead.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]