This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] [PATCH] Implement -ffortify for C/C++
On Tuesday, 30. January 2007 17:45, Jakub Jelinek wrote:
> In glibc headers (as well as libssp headers) -D_FORTIFY_SOURCE=2
> disallows str*/stp* etc. to cross structure field boundaries,
> while mem* still can cross them
You're referring to __builtin_object_size(.., 0) vs __builtin_object_size(..,
1), right?
I'm trying to do that via
+ fn = build_bos_call (TREE_VALUE (params),
+ bos && flag_fortify > 1
+ ? integer_one_node : integer_zero_node);
so it produces __builtin_object_size(.., 1) if it is a str*/stp* related
function and fortify level is > 1. This is how I understood it from reading
the glibc header file (I admit it was late and I was drunk).
> , also %n in *printf is only supported
> if format string is in read-only memory (string literal, _(string
> literal)). With -D_FORTIFY_SOURCE=1 that's all allowed.
I'm setting the flags argument of the printf*chk variants to fortify_flag - 1,
so it should be allowed with -ffortify level 1 and not with level 2 and
above. Where did I make the mistake here? I definitely want it to behave the
same.
Thanks,
Dirk