From patchwork Tue Feb 21 22:59:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 60284 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp265840wrd; Tue, 21 Feb 2023 14:59:29 -0800 (PST) X-Google-Smtp-Source: AK7set9mrFmvRJsKujMAizKzE8lb01QiXtyp6IVXLQzViYzxfLpwa7q03dbg0OWiUvuiSK/HmMK9 X-Received: by 2002:a05:6402:697:b0:4af:5aa1:65d7 with SMTP id f23-20020a056402069700b004af5aa165d7mr1170659edy.27.1677020369223; Tue, 21 Feb 2023 14:59:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677020369; cv=none; d=google.com; s=arc-20160816; b=QT4BgDup/zyXTl0omLH+/iPorPeaz6C95cr1AsByf/m6dQ0LJMHICUKq6fGP9+0Tls xJo/ruNQPvdduZWLSWbJdcNGGiXJaILcnM+yxboTaiDNlnXujNXKiZC7heqs4iBpKHlM WI8xOT+hLi/uCaGy/4hsJIB+zLVou+vlHq4s/DGmDGItrcnzLsM+2rLfDmCoc9RZ18qO wKcD2CrywfFCD5aNRybbe2bMQkFzOWaVzQceCSPjsw8rEWowpFxHgiRbpwkA/rsHZS8u mUBkD0S+4xHg3y6tsVm1DNv/bcV6mt0tRYaw1hzP9zWcPeAGFGRDM1KrIhaApV6NG8ZW zd2w== 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=0quUQInjcmfPQbjgzyhUQfUZPMAj5yokzSO/VjWQNEo=; b=hXM5TqYNRH9+i2cHVbxufYr/7l6kvRCf/3SslDrUJZJf1BAX3iaXD8+gzjn27fXFb9 8D/4ssOb9BwA6boaSjlB91hbqv5zm7ItXi/M8qtYsgkh0PsL7aOydjqgQinfpoakOBhQ lo944knwZroavZBaTbPaPPkz9VzaEbjbhaJZjEmeAG4z1vVsSwzdQqs8nj9aXVp6ryql ytbBfgoC7kqkR119mTcyzO7joYDb8fyKJLizLTYok9/Rcd4NelAEHuN2Ym0t03fzonRh NoK5RnW/0Yy8MIjtTTTk4rM5j8voxIRMsb2NTHyxtINl008IlF2tTKAFUsqqaiKiXMJS M8bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=xYGA9zJY; 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 p23-20020a056402045700b004a21a662064si1343287edw.352.2023.02.21.14.59.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 14:59:29 -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=xYGA9zJY; 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 088723858401 for ; Tue, 21 Feb 2023 22:59:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 088723858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677020368; bh=0quUQInjcmfPQbjgzyhUQfUZPMAj5yokzSO/VjWQNEo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xYGA9zJYDcE0s3xuRjAZLHl1w0d9DvGizvmkQQzCKOHVjxF36a32m0vG94aqvTt4+ rdz8/CZ7bYkoxj9fZRX++mkO+EOs6wNjo0EgesI6ksHiZUCZG5QQoPAsdaPX7h+EqT LZY6FbI56/dVLQgzm7VQThYx5eVfNOfdoyhDr6z0= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by sourceware.org (Postfix) with ESMTPS id 33B213858D39 for ; Tue, 21 Feb 2023 22:59:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33B213858D39 Received: by mail-pj1-x102b.google.com with SMTP id g14so6809423pjb.2 for ; Tue, 21 Feb 2023 14:59:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=0quUQInjcmfPQbjgzyhUQfUZPMAj5yokzSO/VjWQNEo=; b=Fhri6bomjtkIGEpK5cj7keIbKlP6KwcD6Hd1I19+Q/LO/nab6DO1sg52noQlx9bzS4 Zp1QxHpqJqiMYkYhMOMwTFwgU/7XhH9ziuoDhqSC6FWKgEh7sCTsLnYoqnNJtCnAomMJ ZhW1jR+RRxFv9W6NhOML+lf3svMsyriZcQ7duW/Jc8wtkBQDrFEmpZna//HRIuy0SRqr E3mXUhydzLBDRaYJpLbh9DIvTQMIur+7saPrOcCUwSoFdvtpI2A6Vu9L3N6Tm0DuMqYn rp7kRFSF3vX699hgq3BQJL+AHyqJFb8cpGHA0hD/Aw5x6i12kqQOWJKGN99emd6jpqix Orvg== X-Gm-Message-State: AO0yUKWBEwPaNrsmu1JTtCcvpZdVWqa0e70xIZUtwtTS7VsqhGhdTyix ceL6z6AOwonJaU1JHzRqL1ReM1Rd8mk= X-Received: by 2002:a17:902:d4c8:b0:19a:6ec0:50c2 with SMTP id o8-20020a170902d4c800b0019a6ec050c2mr9152316plg.26.1677020358906; Tue, 21 Feb 2023 14:59: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 h2-20020a170902f7c200b00194caf3e975sm10379449plw.208.2023.02.21.14.59.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 14:59:18 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id AF7D71142769; Wed, 22 Feb 2023 09:29:15 +1030 (ACDT) Date: Wed, 22 Feb 2023 09:29:15 +1030 To: binutils@sourceware.org Subject: debug_link duplicate file size checks Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3035.4 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?1758483310851247199?= X-GMAIL-MSGID: =?utf-8?q?1758483310851247199?= bfd_malloc_and_get_section does these checks. * opncls.c (bfd_get_debug_link_info_1): Don't check section size against file size. (bfd_get_alt_debug_link_info): Likewise. diff --git a/bfd/opncls.c b/bfd/opncls.c index 5dacad9b7d4..cdf09b333fa 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -1195,7 +1195,6 @@ bfd_get_debug_link_info_1 (bfd *abfd, void *crc32_out) unsigned int crc_offset; char *name; bfd_size_type size; - ufile_ptr file_size; BFD_ASSERT (abfd); BFD_ASSERT (crc32_out); @@ -1206,10 +1205,9 @@ bfd_get_debug_link_info_1 (bfd *abfd, void *crc32_out) return NULL; size = bfd_section_size (sect); - file_size = bfd_get_size (abfd); /* PR 22794: Make sure that the section has a reasonable size. */ - if (size < 8 || (file_size != 0 && size >= file_size)) + if (size < 8) return NULL; if (!bfd_malloc_and_get_section (abfd, sect, &contents)) @@ -1284,7 +1282,6 @@ bfd_get_alt_debug_link_info (bfd * abfd, bfd_size_type *buildid_len, unsigned int buildid_offset; char *name; bfd_size_type size; - ufile_ptr file_size; BFD_ASSERT (abfd); BFD_ASSERT (buildid_len); @@ -1296,8 +1293,7 @@ bfd_get_alt_debug_link_info (bfd * abfd, bfd_size_type *buildid_len, return NULL; size = bfd_section_size (sect); - file_size = bfd_get_size (abfd); - if (size < 8 || (file_size != 0 && size >= file_size)) + if (size < 8) return NULL; if (!bfd_malloc_and_get_section (abfd, sect, & contents))