From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x102b.google.com with SMTP id g14so6809423pjb.2 for ; Tue, 21 Feb 2023 14:59:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=0quUQInjcmfPQbjgzyhUQfUZPMAj5yokzSO/VjWQNEo=; b=k/MxGb9gFipwWhLJiH0vpYSI1TleZYNGwu8Grp9syz+cxTbtP88MJJ266LVdP4am/I 1/hARMBWJIpy8MU+JaF0d4x8lMDynHMhpM85hw/8oiPbIl2GPl2AQYxD9yGOPCAiAFNh aSrgvM2qMtBDp1aAZNyDpDaL89NwbIhinhbzNNjjfiI9/Gr49JYxOzTW5KVLtNVW9ZVp MmOJJv4OqrpoGXmpXzZlSwNCIiOz3KfPyp+vO4hDN2gf37GQlLw69GEG4pXzHpNTSiMF /rV+24qu/t6lsYsAp3yXN/n8TvU3yRKcsr6JzMsOjKx4AChr+SC5I+Vtc/mH7iI1yjqv l+0w== 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-Google-Smtp-Source: AK7set+X0Nlg0b4ziZNuS4cl+d6ZnIIXon6jSEMn+3aC6zXEQHsySJpLID3XtMjb01B1tkphv9LneQ== 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 From: Alan Modra To: binutils@sourceware.org Subject: debug_link duplicate file size checks Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 List-Id: 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)) -- Alan Modra Australia Development Lab, IBM