From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 39274 invoked by alias); 20 Sep 2017 18:46:08 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 39239 invoked by uid 89); 20 Sep 2017 18:46:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy= X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Sep 2017 18:46:05 +0000 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 1449431F8C30; Wed, 20 Sep 2017 20:46:03 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 00BBA422D713; Wed, 20 Sep 2017 20:46:02 +0200 (CEST) Message-ID: <1505933162.16945.55.camel@klomp.org> Subject: Re: [PATCH] ar: Check whether ar header values fit. From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Matthias Klose Date: Wed, 20 Sep 2017 18:46:00 -0000 In-Reply-To: <1505474076-16062-1-git-send-email-mark@klomp.org> References: <1505474076-16062-1-git-send-email-mark@klomp.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Evolution 3.22.6 (3.22.6-10.el7) Mime-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2017-q3/txt/msg00120.txt.bz2 On Fri, 2017-09-15 at 13:14 +0200, Mark Wielaard wrote: > When compiling with -O3 gcc finds an interesting error: >=20 > src/ar.c: In function =E2=80=98do_oper_insert=E2=80=99: > src/ar.c:1077:56: error: =E2=80=98%-*ld=E2=80=99 directive output may be = truncated > writing between 6 and 10 bytes into a region of size 7 [- > Werror=3Dformat-truncation=3D] > =C2=A0=C2=A0=C2=A0snprintf (tmpbuf, sizeof (tmpbuf), ofmt ? "%-*lo" : "%-= *ld", > bufsize, val); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0^~~~~ > The problem is that the ar header values have to fit in a limited > (not zero terminated) string. We should check the snprintf return > value to see if the values are representable. >=20 > Also make ar valgrind and ubsan clean and add a minimal sanity test. I pushed this to master.