[Bug middle-end/49905] Better sanity checking on sprintf src & dest to produce warning for dodgy code ?

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jul 4 17:24:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49905

--- Comment #15 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to David Binderman from comment #11)
> BTW, I tried a Linux kernel build and got this
> 
> drivers/char/ipmi/ipmi_msghandler.c: In function ‘guid_show’:
> drivers/char/ipmi/ipmi_msghandler.c:2365:9: internal compiler error: in
> format_integer, at c-family/c-format.c:506
>   return snprintf(buf, 100, "%Lx%Lx\n",
>          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     (long long) bmc->guid[0],
>     ~~~~~~~~~~~~~~~~~~~~~~~~~
>     (long long) bmc->guid[8]);
>     ~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> So it looks to me like format %Lx isn't handled.
...
> Also, %lf seems to cause a crash.

Not all directives or length modifiers are recognized yet but they should be
handled gracefully, not by aborting.  (In most cases the checker gives up on
the rest of the format strings).  Thanks for pointing out these cases, I'll
update the code in the next revision of the patch.


More information about the Gcc-bugs mailing list