From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 44330 invoked by alias); 3 Dec 2019 09:47:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 44322 invoked by uid 89); 3 Dec 2019 09:47:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=H*F:D*ru X-HELO: mail-vk1-f195.google.com Received: from mail-vk1-f195.google.com (HELO mail-vk1-f195.google.com) (209.85.221.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Dec 2019 09:47:50 +0000 Received: by mail-vk1-f195.google.com with SMTP id x199so876184vke.6 for ; Tue, 03 Dec 2019 01:47:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=frtk-ru.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=i4Rq6iSJuJis+LK7P4ZoDI3URCJ+QD6z5ubOgPqcxcs=; b=nGOrj7z+cNvzf3UeW1mtWp2CPJsNAa93o0JPN++U+Vog3A9dfVR5Vg5FQjeEOjXTkX M7CtWTBMJvA4cPflc0JkIBskhUzYLnwkDfRk40N/MXKpD+ocO2KWAZgJp4azVkVwecSi Nu1guOsgGRlm+RVFl277SnASXUzsHjd7cRJAtWXUr78ZateEValA1mjreu3Lc6iCouOU z0qvCrh3LMjXnqUFg9pr8vgnb74exdjLGDoc3GcJMFdVfMSEJ7f5w72Lu3uyKTVLE7Jd CTzjyPeoPVW9RNUEmm8LZgv6jGwp+baIltcSw4/zGRYN+Y8APBg2mANeANNizBYLqsYl B6iA== MIME-Version: 1.0 References: <20191202100948.GJ3410@embecosm.com> <20191202212031.GK3410@embecosm.com> In-Reply-To: <20191202212031.GK3410@embecosm.com> From: "Pavel I. Kryukov" Date: Tue, 03 Dec 2019 09:47:00 -0000 Message-ID: Subject: Re: [PATCH] sim-utils.c: prevent buffer overflow. To: Andrew Burgess Cc: Simon Marchi , gdb-patches@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-SW-Source: 2019-12/txt/msg00084.txt.bz2 Thanks. Could you please tell if there is any action required from me? -- Pavel =D0=B2=D1=82, 3 =D0=B4=D0=B5=D0=BA. 2019 =D0=B3. =D0=B2 00:20, Andrew Burge= ss : > > * Pavel I. Kryukov [2019-12-02 22:06:04 +0300]: > > > From 2d6383b7baa715d65191f0f6818ecdd8f5e8fc7d Mon Sep 17 00:00:00 2001 > > From: "Pavel I. Kryukov" > > 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 > > > > * 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 > > + > > + * sim-utils.c: Prevent buffer overflow. > > + > > 2019-09-23 Dimitar Dimitrov > > > > * 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 >