public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Pavel I. Kryukov" <kryukov@frtk.ru>
To: gdb-patches@sourceware.org
Subject: [PATCH] sim-utils.c: prevent buffer overflow.
Date: Sat, 30 Nov 2019 22:54:00 -0000	[thread overview]
Message-ID: <CADip9gbhoNmoS358B4wsw1wbX7AjT+5qxw+7bRoZcowXGv7wsw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0001-sim-utils.c-prevent-buffer-overflow.patch --]
[-- Type: application/octet-stream, Size: 1519 bytes --]

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.
---
 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);
 	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);
 	return str;
       }
-- 
2.7.4


             reply	other threads:[~2019-11-30 22:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-30 22:54 Pavel I. Kryukov [this message]
2019-12-01 14:46 ` Simon Marchi
2019-12-01 15:33   ` Павел Крюков
2021-01-15  5:18     ` Mike Frysinger
2019-12-02 10:09 ` Andrew Burgess
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=CADip9gbhoNmoS358B4wsw1wbX7AjT+5qxw+7bRoZcowXGv7wsw@mail.gmail.com \
    --to=kryukov@frtk.ru \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).