From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id D5F953858C39 for ; Wed, 8 Dec 2021 23:14:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D5F953858C39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from reform (deer0x03.wildebeest.org [172.31.17.133]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id A800F3000ED0 for ; Thu, 9 Dec 2021 00:14:29 +0100 (CET) Received: by reform (Postfix, from userid 1000) id 57CB12E8073E; Thu, 9 Dec 2021 00:14:13 +0100 (CET) Date: Thu, 9 Dec 2021 00:14:13 +0100 From: Mark Wielaard To: elfutils-devel@sourceware.org Subject: Re: [PATCH] readelf: Workaround stringop-truncation error Message-ID: References: <20211204211504.276502-1-mark@klomp.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20211204211504.276502-1-mark@klomp.org> X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Dec 2021 23:14:32 -0000 On Sat, Dec 04, 2021 at 10:15:04PM +0100, Mark Wielaard wrote: > In function ‘strncpy’, > inlined from ‘print_ehdr’ at readelf.c:1175:4: > error: ‘__builtin_strncpy’ specified bound 512 equals destination size > [-Werror=stringop-truncation] > > strncpy doesn't terminate the copied string if there is not enough > room. We compensate later by explicitly adding a zero terminator at > buf[sizeof (buf) - 1]. Normally gcc does see this, but with > -fsanitize=address there is too much (checking) code in between. But > it is actually better to not let strncpy do too much work, so > substract one from the size. Pushed, Mark