[PATCH] sim-utils.c: prevent buffer overflow.
Pavel I. Kryukov
kryukov@frtk.ru
Mon Dec 2 12:00:00 GMT 2019
> > diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c
> > index e83a2e4..a60dd92 100644
> > --- a/sim/common/sim-utils.c
> > +++ b/sim/common/sim-utils.c
> > @@ -355,7 +355,7 @@ map_to_str (unsigned map)
> > case io_map: return "io";
> > default:
> > {
> > - static char str[10];
> > + static char str[16];
> > sprintf (str, "(%ld)", (long) map);
>
> I think you could/should change this call to sprintf to use
> xsnprintf instead.
If I understand correctly, xsnprintf is defined in GDB header
(gdb/gdbsupport/common-utils.h) which is C++.
Can we use "pure" snprintf instead?
Thanks,
--
Pavel
More information about the Gdb-patches
mailing list