This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] sim-utils.c: prevent buffer overflow.
Thanks. Could you please tell if there is any action required from me?
--
Pavel
вт, 3 дек. 2019 г. в 00:20, Andrew Burgess <andrew.burgess@embecosm.com>:
>
> * Pavel I. Kryukov <kryukov@frtk.ru> [2019-12-02 22:06:04 +0300]:
>
> > From 2d6383b7baa715d65191f0f6818ecdd8f5e8fc7d Mon Sep 17 00:00:00 2001
> > From: "Pavel I. Kryukov" <kryukov@frtk.ru>
> > Date: Sun, 1 Dec 2019 01:40:21 +0300
> > Subject: [PATCH] sim-utils.c: prevent buffer overflow.
> >
> > Representation of max 32-bit integer is 10 chars.
> > The potential issue is observed by GCC 7 targeted to AArch64.
> >
> > sim/common/ChangeLog:
> > 2019-12-01 Pavel I. Kryukov <kryukov@frtk.ru>
> >
> > * sim-utils.c: Prevent buffer overflow.
>
> Approved.
>
> Sorry about the xsnprintf confusion - I'd assumed that came from
> libiberty, my mistake.
>
> Thanks,
> Andrew
>
>
>
> > ---
> > sim/common/ChangeLog | 4 ++++
> > sim/common/sim-utils.c | 8 ++++----
> > 2 files changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
> > index a7ec5c7..12d900e 100644
> > --- a/sim/common/ChangeLog
> > +++ b/sim/common/ChangeLog
> > @@ -1,3 +1,7 @@
> > +2019-12-01 Pavel I. Kryukov <kryukov@frtk.ru>
> > +
> > + * sim-utils.c: Prevent buffer overflow.
> > +
> > 2019-09-23 Dimitar Dimitrov <dimitar@dinux.eu>
> >
> > * gennltvals.sh: Add PRU libgloss target.
> > diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c
> > index e83a2e4..0c46662 100644
> > --- a/sim/common/sim-utils.c
> > +++ b/sim/common/sim-utils.c
> > @@ -355,8 +355,8 @@ map_to_str (unsigned map)
> > case io_map: return "io";
> > default:
> > {
> > - static char str[10];
> > - sprintf (str, "(%ld)", (long) map);
> > + static char str[16];
> > + snprintf (str, sizeof(str), "(%ld)", (long) map);
> > return str;
> > }
> > }
> > @@ -385,8 +385,8 @@ access_to_str (unsigned access)
> > case access_read_write_exec_io: return "read_write_exec_io";
> > default:
> > {
> > - static char str[10];
> > - sprintf (str, "(%ld)", (long) access);
> > + static char str[16];
> > + snprintf (str, sizeof(str), "(%ld)", (long) access);
> > return str;
> > }
> > }
> > --
> > 2.7.4
>