From patchwork Wed Jul 24 06:59:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1136100 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-505583-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="fznj/JpT"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45tmSJ6K23z9s3l for ; Wed, 24 Jul 2019 16:59:58 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:message-id:date:mime-version:content-type; q=dns; s=default; b=uuWAAycv5rebP8xDpkjNjOQSkSlH9r3a/AzDmEce0gvjwNZ5qU TIzjh5xcH8upivhQAxx5dMEFuUHBJUlJWo6sSlNnyvU+wlsWch+m0YSRVs88MLI0 CGaLzZYgDSrjkH4A3HNjGhRUzKf3gyhYm0nx+mhdOhNTINhhS2l5GTx/Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:message-id:date:mime-version:content-type; s= default; bh=1W6/e68rVYQHz4eylU/MDrzL2iQ=; b=fznj/JpT6grGPQf5fjjQ 4QPayYD/Nxn6pkWWIRQlMtljSK6MLjfHLoGQX2Zi+4eyw8hbYGvyDFOssFY/X5WM 67SZPeKY0Wyp0NET8wmc6+Lw6h5P0I9Zp6AFKepbGKlgbqlMEXr5jJUnqLLD4dCI 2vZdVD9KRfEbT1Wbab6cmXQ= Received: (qmail 80439 invoked by alias); 24 Jul 2019 06:59:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 80430 invoked by uid 89); 24 Jul 2019 06:59:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 24 Jul 2019 06:59:49 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CCAE4ABF1; Wed, 24 Jul 2019 06:59:46 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Fix off-by-one in simple-object-elf.c (PR lto/91228). To: gcc-patches@gcc.gnu.org Cc: Richard Biener Message-ID: <9a3d4bfe-aa4c-2fbb-2e95-0e41f510e91f@suse.cz> Date: Wed, 24 Jul 2019 08:59:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi. The patch is about off-by-one error that I used for a wrong argument. I consider that pre-approved by Richi. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Thanks, Martin libiberty/ChangeLog: 2019-07-23 Martin Liska PR lto/91228 * simple-object-elf.c (simple_object_elf_copy_lto_debug_sections): Find first '\0' starting from gnu_lto + 1. --- libiberty/simple-object-elf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c index bdee963634d..75159266596 100644 --- a/libiberty/simple-object-elf.c +++ b/libiberty/simple-object-elf.c @@ -1388,8 +1388,8 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj, (unsigned char *)strings, strsz, &errmsg, err); /* Find first '\0' in strings. */ - gnu_lto = (char *) memchr (gnu_lto, '\0', - strings + strsz - gnu_lto + 1); + gnu_lto = (char *) memchr (gnu_lto + 1, '\0', + strings + strsz - gnu_lto); /* Read the section index table if present. */ if (symtab_indices_shndx[i - 1] != 0) {