From: Andrew Cagney <ac131313@redhat.com>
To: Daniel Jacobowitz <drow@mvista.com>, Kevin Buettner <kevinb@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: PATCH: Add type_sprint() function to return type in string form
Date: Tue, 22 Apr 2003 21:15:00 -0000 [thread overview]
Message-ID: <3EA5B0F2.5000908@redhat.com> (raw)
In-Reply-To: <20030422192827.GA21651@nevyn.them.org>
>> You're kidding right?
>>
>> The ARI indicates that all sprintf calls should be replaced with either
>> snprintf or xasprintf.
>>
>> Replacing sprintf with functions that are immune to buffer overrun
>> problems, eliminates an entire class of bug.
>>
>> Even something as simple as:
>> char buf[100000000];
>> sprintf (buf, _("a"));
>> is broken.
>
>
> No, I'm not kidding. I've worked in computer security for about six
> years now and I still use sprintf. It's simple, it's effective, and if
> you use it reasonably carefully, nothing will go wrong.
That also applies to snprintf and xasprintf.
> Not to mention that there are a number of buggy implementations of
> snprintf; they're slowly starting to fade from use, thank the lord, but
> you still see 'em now and again.
If GDB encounters a system with a buggy snprintf implementation, it
should use the one in libiberty. If libiberty's is buggy, some one
should fix it.
> Of course, in those six years I've had this argument about ten times.
> It seems to be about a 50/50 split between developers.
> And nothing involving translation is simple.
There are tradeoffs.
Things like the 80/20 rule (80% of bugs fixed with 20% of the effort);
zero tolerance (complete elimination of risky coding pratices).
This was seen with Kevin's recent elimination of of complain that
flushed out numerous -Wformat problems.
As for replacing the existing sprintf calls, like STREQ et.al., anyone
wanting to do this will need to come up with a way of demonstrating that
the translation was `probably' correct. One trick is to only convert
lines that GCOV identifies as being executed.
Andrew
next prev parent reply other threads:[~2003-04-22 21:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-18 22:24 Jason Molenda
2003-04-22 3:26 ` Daniel Jacobowitz
2003-04-22 16:48 ` Andrew Cagney
2003-04-22 16:55 ` Daniel Jacobowitz
2003-04-22 17:29 ` Andrew Cagney
2003-04-22 17:33 ` Daniel Jacobowitz
2003-04-22 19:21 ` Andrew Cagney
2003-04-22 19:28 ` Daniel Jacobowitz
2003-04-22 20:16 ` Andrew Cagney
2003-04-22 20:22 ` Daniel Jacobowitz
2003-04-22 20:35 ` Jason Molenda
2003-04-22 21:15 ` Andrew Cagney [this message]
2003-04-22 19:55 ` Kevin Buettner
2003-04-23 14:23 ` Jason Molenda
2003-04-23 17:37 ` Andrew Cagney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3EA5B0F2.5000908@redhat.com \
--to=ac131313@redhat.com \
--cc=drow@mvista.com \
--cc=gdb-patches@sources.redhat.com \
--cc=kevinb@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox