qemu/disas
Philippe Mathieu-Daudé 2037a73997 disas/cris: Pass buffer size to format_dec() to avoid overflow warning
Propagate the buffer size to format_dec() and use snprintf().

This should silence this UBSan -Wformat-overflow warning:

  In file included from /usr/include/stdio.h:906,
                   from include/qemu/osdep.h:114,
                   from ../disas/cris.c:21:
  In function 'sprintf',
      inlined from 'format_dec' at ../disas/cris.c:1737:3,
      inlined from 'print_with_operands' at ../disas/cris.c:2477:12,
      inlined from 'print_insn_cris_generic.constprop' at ../disas/cris.c:2690:8:
  /usr/include/bits/stdio2.h:30:10: warning: null destination pointer [-Wformat-overflow=]
   30 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   31 |                                   __glibc_objsize (__s), __fmt,
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   32 |                                   __va_arg_pack ());
      |                                   ~~~~~~~~~~~~~~~~~

Reported-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231120132222.82138-1-philmd@linaro.org>
[Rewritten to fix logic and avoid repeated expression. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2023-11-24 16:21:55 +01:00
..
alpha.c
capstone.c
cris.c disas/cris: Pass buffer size to format_dec() to avoid overflow warning 2023-11-24 16:21:55 +01:00
disas-internal.h
disas-mon.c
disas.c
hexagon.c
hppa.c disas/hppa: Show hexcode of instruction along with disassembly 2023-11-17 18:36:36 +01:00
m68k.c disas/m68k: clean up local variable shadowing 2023-09-29 10:07:21 +02:00
meson.build
microblaze.c
mips.c
nanomips.c
nios2.c
riscv-xthead.c
riscv-xthead.h
riscv-xventana.c
riscv-xventana.h
riscv.c disas/riscv: Replace TABs with space 2023-11-07 11:06:02 +10:00
riscv.h disas/riscv: Add rv_codec_vror_vi for vror.vi 2023-11-07 11:06:02 +10:00
sh4.c
sparc.c
xtensa.c