public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] sim-utils.c: prevent buffer overflow.
Date: Wed, 04 Dec 2019 21:13:00 -0000	[thread overview]
Message-ID: <f47674be8e90a84edae49ec2b781201ea2f050bd@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT f47674be8e90a84edae49ec2b781201ea2f050bd ***

commit f47674be8e90a84edae49ec2b781201ea2f050bd
Author:     Pavel I. Kryukov <kryukov@frtk.ru>
AuthorDate: Sun Dec 1 01:40:21 2019 +0300
Commit:     Tom Tromey <tromey@adacore.com>
CommitDate: Wed Dec 4 10:38:08 2019 -0700

    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.

diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index a7ec5c7121..12d900e8b6 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 e83a2e4d0c..0c46662ff3 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;
       }
     }


             reply	other threads:[~2019-12-04 20:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04 21:13 gdb-buildbot [this message]
2019-12-04 20:57 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot
2019-12-04 21:22 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, " gdb-buildbot
2019-12-04 21:42 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2019-12-05  2:15 ` Failures on Fedora-i686, " gdb-buildbot
2019-12-05  2:49 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2019-12-05  2:56 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2019-12-05  3:01 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot
2019-12-05  3:04 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot

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=f47674be8e90a84edae49ec2b781201ea2f050bd@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@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).