From patchwork Mon Mar 6 03:32:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 64418 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1639998wrd; Sun, 5 Mar 2023 19:33:34 -0800 (PST) X-Google-Smtp-Source: AK7set/rkMkPbhwq+CjqaUT0JtccnOWlqg9Db70uMSnHOzk55WpO2IP0dt8FFJpnr9JICN1JQ5RB X-Received: by 2002:a17:907:1ca3:b0:8ea:2055:4f1b with SMTP id nb35-20020a1709071ca300b008ea20554f1bmr12181627ejc.24.1678073614422; Sun, 05 Mar 2023 19:33:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678073614; cv=none; d=google.com; s=arc-20160816; b=eE0BQtQLus/BBUL12jgI8vPurG79oKkcI8B3J3K7EOCvbENFfh3XX32e/cBYmbODa9 VsZJPWUalYq0sTVNftrGQEbUN5u+XCyP/tWjNvzEierJqEhs5GX78rBNpnTpase+XijO FbBFKNbkBWBI/Go0r/I6iom4QfoPiD3qlQ84aY8rGkKTi9OcxyuoYXQ1ZD7etCsWTdN2 vXJw1CsXe7AEmhhWQMXxkYn3Tue81da6lrGzKRb4RZ9IhSZrdASh26AFQleTqZBrG4vb /V4lr2sf+euTDnNdNz4VXxHbJYf1r0J2l4S+6jAgweoY6FEyoHc28o2Ao6kHS1sIGHXO l8lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=qi9ZjDiDa4LP0ILKcnhdzVNVy6IrM/CHjlg02rSn/gc=; b=aTxb0qPxQpk/bLXKNNUFwtUHps/dKWkDcGBprXIE7l3ZCcwnOG/O4NTcc046O7VNG5 M0GD2NG7/v6bymW+w9j7nLU32jjVUHs6BrDz48bkD9T6fUS0xvRDX0UhXAEWFbRRsmjj VLqs6z5dez+/0A20ZG3lxA5y1GlEqmZ3Y8vM1QEVdUceVzCQnQOzO4FjnDEVyr6i1H9a 51XMpntY85K+K1hny0nnmlqmRGuUlDLs+9Gedh9zkuBiFGM7LtBcV3vts9YybcBzYEgB FzGkYMBKo0SH4cSXcKFeGUfk69zNdp9C5rV9gWuC9DnaFn+bEPIHrcB4zEldvhJGHzqy +UjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NxQBFRg1; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d9-20020a170906304900b008d20a6a9d98si9540100ejd.279.2023.03.05.19.33.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Mar 2023 19:33:34 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NxQBFRg1; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 04B003850852 for ; Mon, 6 Mar 2023 03:33:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04B003850852 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678073600; bh=qi9ZjDiDa4LP0ILKcnhdzVNVy6IrM/CHjlg02rSn/gc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=NxQBFRg1+szhvybnrui5XBDmEu3yotGzJZUGvAlTp5dP8QnvzAXsp4SCwZijHkWIA dOYp86RWpPF9ifufZ0VwE5N84methfwOSvxKvuGspOKjO0S9AbPydd3SlJO/25eVNN 9pA6V1zdNYr7ngJpXlhvvJvlKJDjFELDX0H3uFA8= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 7F5B73857C43 for ; Mon, 6 Mar 2023 03:32:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F5B73857C43 Received: by mail-pl1-x635.google.com with SMTP id h8so8786584plf.10 for ; Sun, 05 Mar 2023 19:32:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678073538; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qi9ZjDiDa4LP0ILKcnhdzVNVy6IrM/CHjlg02rSn/gc=; b=uSmWKejXwFKrxzuZ1+3Aq1ZvA/qCzykERio44CAgcn99WBBrL9zvMc3EXJMiyJCsO5 BDpBClHt53ZXnlvYlE64Pc1CE+eOZlIs6wXml7gNO1yllDOKPvM5cd6aOYwKudTbTxPb 65JxlB6jkm/TZB3NW9u4NgK64vnQOylNADdZZw0BJqOn9GLDtzqdcA1d/Q8/5fKSb88+ aIYE00RNiU1lGxOxJx9hb6N2Lkzk1v5e+csjEh/9H1UWqLGXPMy5TQ8a9LPZwexceL8M r4r6Ayv9iCX/ut+4CsRJ/Soye1UeG2/QuN12Vka88zjAYcEb9xVkcS+9ltDRAP8wPEfX NIbA== X-Gm-Message-State: AO0yUKWpKgvaPWitPKRHReJcxD0ImxTwVZZgeVdgu/nnd6YbjlkS+Hnl mbhnDTFNVUhrZHHhvNG/XqJHnBLPLkI= X-Received: by 2002:a17:902:ecc6:b0:19e:8688:86fe with SMTP id a6-20020a170902ecc600b0019e868886femr12070498plh.42.1678073538369; Sun, 05 Mar 2023 19:32:18 -0800 (PST) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id v5-20020a1709028d8500b001960706141fsm5407530plo.149.2023.03.05.19.32.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Mar 2023 19:32:18 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 10ED01142C90; Mon, 6 Mar 2023 14:02:16 +1030 (ACDT) Date: Mon, 6 Mar 2023 14:02:16 +1030 To: binutils@sourceware.org Subject: More _bfd_ecoff_locate_line sanity checks Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3035.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759587718360375405?= X-GMAIL-MSGID: =?utf-8?q?1759587718360375405?= * ecofflink.c (mk_fdrtab): Discard fdr with negative cpd. (lookup_line): Sanity check fdr cbLineOffset and cbLine. Sanity check pdr cbLineOffset. diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c index 00f1e3da404..bba25929f2c 100644 --- a/bfd/ecofflink.c +++ b/bfd/ecofflink.c @@ -1742,6 +1742,7 @@ mk_fdrtab (bfd *abfd, /* Sanity check fdr procedure descriptor pointer. */ long ipdMax = debug_info->symbolic_header.ipdMax; if (fdr_ptr->ipdFirst >= ipdMax + || fdr_ptr->cpd < 0 || fdr_ptr->cpd > ipdMax - fdr_ptr->ipdFirst) fdr_ptr->cpd = 0; /* Skip FDRs that have no PDRs. */ @@ -2146,12 +2147,20 @@ lookup_line (bfd *abfd, are stored in a very funky format, which I won't try to describe. The search is bounded by the end of the FDRs line number entries. */ - line_end = debug_info->line + fdr_ptr->cbLineOffset + fdr_ptr->cbLine; + line_ptr = line_end = debug_info->line; + if (fdr_ptr->cbLineOffset < debug_info->symbolic_header.cbLine + && fdr_ptr->cbLine <= (debug_info->symbolic_header.cbLine + - fdr_ptr->cbLineOffset) + && pdr.cbLineOffset <= (debug_info->symbolic_header.cbLine + - fdr_ptr->cbLineOffset)) + { + line_end += fdr_ptr->cbLineOffset + fdr_ptr->cbLine; + line_ptr += fdr_ptr->cbLineOffset + pdr.cbLineOffset; + } /* Make offset relative to procedure entry. */ offset -= pdr.adr - 0x10 * pdr.prof; lineno = pdr.lnLow; - line_ptr = debug_info->line + fdr_ptr->cbLineOffset + pdr.cbLineOffset; while (line_ptr < line_end) { int delta;