]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
avoid bogus format-overflow error
authorAlan Modra <amodra@gmail.com>
Sun, 20 Apr 2025 23:33:52 +0000 (09:03 +0930)
committerAlan Modra <amodra@gmail.com>
Sun, 20 Apr 2025 23:33:52 +0000 (09:03 +0930)
commit9c7ed7b7fdbe4e25b4bad5e64f5d37936e4c9045
treeff8332ddd5274355c7879d3fe5cd49a88b4cb55b
parent7dc5df8e5d374fa6fec2f2a6b7d1bbc258095d47
avoid bogus format-overflow error

Seen on x86_64-linux Ubuntu 24.04.2 using gcc-13.3.0 with
CFLAGS="-m32 -g -O2 -fsanitize=address,undefined"

In function ‘sprintf’,
    inlined from ‘s_mri_for’ at gas/config/tc-m68k.c:6941:5:
/usr/include/bits/stdio2.h:30:10: error: null destination pointer [-Werror=format-overflow=]
   30 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   31 |                                   __glibc_objsize (__s), __fmt,
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   32 |                                   __va_arg_pack ());
      |                                   ~~~~~~~~~~~~~~~~~

Rewrite the code without sprintf, as in other parts of s_mri_for.
See also commit 760fb390fd4c and following commits.

Note that adding -D_FORTIFY_SOURCE=0 to CFLAGS (which is a good idea
when building with sanitizers) merely transforms the sprintf_chk error
here into one regarding plain sprintf.
gas/config/tc-m68k.c