GCC extension for protecting applications from format string attacks

Steve Beattie steve@wirex.net
Fri Apr 6 12:03:00 GMT 2001


On Thu, Apr 05, 2001 at 01:46:23PM -0700, Richard Henderson wrote:
> Probably the best solution to this is to not do ugly things with data in
> text sections, nor hidden parameters, but to redefine printf as a macro:
> 
> #define printf(FMT, ...) \
>   xprintf(check_it(__VA_LIST__), (FMT), ## __VA_LIST__)
> 
> where check_it could be one of those awful macro hacks that counts
> parameters, or it could be a new builtin that returns a char array
> (aka string constant) of enum type_class values.  Or something.

I'd like to point out that our FormatGuard patch to glibc (attached)
does exactly the awful macro counting trick that you suggest. See
http://www.immunix.org/formatguard.html for more details. 

-- 
Steve Beattie                               Don't trust programmers? 
<steve@wirex.net>                         Complete StackGuard distro at
http://immunix.org/~steve/                         immunix.org


More information about the Gcc-patches mailing list