Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: "Pavel I. Kryukov" <kryukov@frtk.ru>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] sim-utils.c: prevent buffer overflow.
Date: Mon, 02 Dec 2019 10:09:00 -0000	[thread overview]
Message-ID: <20191202100948.GJ3410@embecosm.com> (raw)
In-Reply-To: <CADip9gbhoNmoS358B4wsw1wbX7AjT+5qxw+7bRoZcowXGv7wsw@mail.gmail.com>

* Pavel I. Kryukov <kryukov@frtk.ru> [2019-12-01 01:53:59 +0300]:

> 

> From 5958a57053a755030e930c63168f09ca8fab1c84 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 with the nit below fixed.

Thanks,
Andrew

> ---
>  sim/common/ChangeLog   | 4 ++++
>  sim/common/sim-utils.c | 4 ++--
>  2 files changed, 6 insertions(+), 2 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..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.

>         return str;
>        }
> @@ -385,7 +385,7 @@ access_to_str (unsigned access)
>      case access_read_write_exec_io: return "read_write_exec_io";
>      default:
>        {
> -       static char str[10];
> +       static char str[16];
>         sprintf (str, "(%ld)", (long) access);

Same.

>         return str;
>        }


  parent reply	other threads:[~2019-12-02 10:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-30 22:54 Pavel I. Kryukov
2019-12-01 14:46 ` Simon Marchi
2019-12-01 15:33   ` Павел Крюков
2021-01-15  5:18     ` Mike Frysinger via Gdb-patches
2019-12-02 10:09 ` Andrew Burgess [this message]
2019-12-02 12:00   ` Pavel I. Kryukov
2019-12-02 19:06     ` Pavel I. Kryukov
2019-12-02 21:20       ` Andrew Burgess
2019-12-03  9:47         ` Pavel I. Kryukov
2019-12-04 17:39           ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191202100948.GJ3410@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=kryukov@frtk.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox