This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch to add __builtin_printf

Zack Weinberg <> writes:

| On Tue, 19 Sep 2000 16:21:08 -0400 (EDT), "Kaveh R. Ghazi" wrote:
| > > From: Zack Weinberg <>
| > > 
| > > 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
be polished.

-- Gaby
CodeSourcery, LLC                   

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]