This is the mail archive of the
mailing list for the GCC project.
Re: Patch to add __builtin_printf
- To: Zack Weinberg <zack at rabi dot columbia dot edu>
- Subject: Re: Patch to add __builtin_printf
- From: Gabriel Dos Reis <gdr at codesourcery dot com>
- Date: 20 Sep 2000 08:56:16 +0200
- Cc: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>, gcc-patches at gcc dot gnu dot org
- Organization: CodeSourcery, LLC
- References: <200009200610.CAA11791@blastula.phys.columbia.edu>
Zack Weinberg <firstname.lastname@example.org> writes:
| On Tue, 19 Sep 2000 16:21:08 -0400 (EDT), "Kaveh R. Ghazi" wrote:
| > > From: Zack Weinberg <email@example.com>
| > >
| > > In light of recent security advisories, I'd like to see us do a
| > > transformation like this:
| > >
| > > char *foo; printf (foo); -> printf ("%s", foo); [->fputs (foo, stdout)
| > >
| > > and issue a loud warning about the potential hole. Note that the
| > > transformation only applies when there are no arguments after the variable.
| >I'm about to submit patches to achieve: printf("%s",foo)->fputs(foo,stdout)
| >(Capturing stdout was the hairy part.) So that much you can count on.
| Hm... Appears to me you're working too hard. You know you are using GCC's
| preprocessor, therefore you can inject
| #undef printf
| #define printf(args...) fprintf(stdout, args...)
I'm not sure that will interact nicely with the following C++
Names that are defined as functions in C shall be defined as
functions in C++ Standard Library.
Personally, I'd favor the approach taken by Kaveh even if it needs to
CodeSourcery, LLC http://www.codesourcery.com