From patchwork Thu Oct 27 07:36:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 11627 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp85549wru; Thu, 27 Oct 2022 00:36:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6IEmQ4tT8O9vgO2gz8VsXeGcZ/Q8gUMaUtJBkuK/+xIZyt+ntDMGJs3mPiHjxWW3QOL9pj X-Received: by 2002:a17:906:8a7b:b0:7ac:baef:6de1 with SMTP id hy27-20020a1709068a7b00b007acbaef6de1mr10197203ejc.734.1666856208023; Thu, 27 Oct 2022 00:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666856208; cv=none; d=google.com; s=arc-20160816; b=D2HLuh6jIEVdd/Rf358p/i0SIiD86YYJy3nrtUrZ6uK87kIdNgs7wT48RB16pglpJz 73QCczPjKFFA1VCNiL54F3dgKkQRoMnYScvp6ted9dnzU2XgoD7NDZZD8W7tsMgFuMZU hqrKyc3jV6oDWeSKfDh95p0n4X1urUE2T5KIRTNJTY3ix8rfKPodFnzlN3TOQXNOw73x pH32FItsRGEi56DXmeQpu1rj+17UypmGkBRD1LdgYnXSQ0iwIjmLr4roUiR27N0x456O ECNUKC7IWx+HSXg1xWpSjD5I6YaWmmEfI+NibcMeY9kzb0Hd1IpZs+u9D46SXsleoYCe +qJw== 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=xNE43y0Wm8K62DOkqHunj3BtWI/mkr34CIic3hGhc5Y=; b=tbJ1i3JGDNEV+P9Mj76dn2tqr2PvpGD15v/omI9dWquPewPF6Sk92EL5PloQCYsVwx UD9rzzrdCrCWcUa7/FNr/22lp4AwSIpKFQGtVg+OzmQ/cT8abieidqJhDUAFK9hWsenE AnFVepGYXoug7hyRJ0B9Fr8GKX6u5aokzCrB5wJYRbGlxLoKLERpscdjZfGwcq0n7wtT ddgks9NKnZcRl6ki0q6Jk7sJxo0l/nMBc2bbPr0DOmZCDhRG4nwtf3VNvTRPJvI0gJ0i nsRSeSREqb1RpWMfnNm6fv5ERnKPFdTqZYVV9WUnBSCse79dvOLSN+bUdg1RM6Xi5uVW DWWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=s6dqHArT; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ht21-20020a170907609500b00770872942d8si798803ejc.958.2022.10.27.00.36.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 00:36:48 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=s6dqHArT; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 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 12994382EA35 for ; Thu, 27 Oct 2022 07:36:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12994382EA35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666856207; bh=xNE43y0Wm8K62DOkqHunj3BtWI/mkr34CIic3hGhc5Y=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=s6dqHArTbFz144rU23dIrUPqmBzuwWx+ycwn81doghptg7vd1Q+OJk5PWWr0BuDJb j7ly1TSwMGCDCHfvNecYRemsFjUd4lQsZZq///n+HTvWlllNf78KcDgN5njE1oYEgz 4SjTou3cg9JJ1mBLi0dSnLxf63Hc4jdPS/qS/Yno= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 5844D382EA07 for ; Thu, 27 Oct 2022 07:36:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5844D382EA07 Received: by mail-pf1-x430.google.com with SMTP id m6so740486pfb.0 for ; Thu, 27 Oct 2022 00:36:37 -0700 (PDT) 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=xNE43y0Wm8K62DOkqHunj3BtWI/mkr34CIic3hGhc5Y=; b=MLKnx+1oTNLARIyPqXAcbDBuSWWz4GFX+aw94tAU4aFsmo+eUPX61YFNN7Lhi/jN4X zMTOynzKPKRlopSUpEgiZa92Q3iSPaEmn8F7d3JWJaK7c+6mpSn3gsPSbhZsvzO3EqS1 AhjFfYNQHj9vKfKS65ZY9wiLEFAQ+BtDUJalVGGCYE5ByTKUczZzSetUCSYSZDRmrYgP SepOtn8YDGLPRGkg+Wqc1LKF5aWyndnPqsne+JlvlcugVEJVI7gtN1q/J82ziy9PJzmW j5H3ClqD414GTED4aBisK2eAOaPFKHWikJh7P0fftgHW3Nh8uqNIbyL4VP2YQWKoEr4v uvuw== X-Gm-Message-State: ACrzQf3RZFsly4y9ZnpM5pzeL9qf1OvxII3Mmg4Z0wRnFru8W8CpArXY hoD6XQoW+XO1cMBktRpq03D/GVaoWLs= X-Received: by 2002:a17:902:9a07:b0:178:8024:1393 with SMTP id v7-20020a1709029a0700b0017880241393mr48078733plp.128.1666856185589; Thu, 27 Oct 2022 00:36:25 -0700 (PDT) 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 l17-20020a170902d05100b001782a6fbcacsm527276pll.101.2022.10.27.00.36.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 00:36:12 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 95B2A1142D8A; Thu, 27 Oct 2022 18:06:08 +1030 (ACDT) Date: Thu, 27 Oct 2022 18:06:08 +1030 To: binutils@sourceware.org Subject: Fuzzed files in archives Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3036.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?1747825415296942815?= X-GMAIL-MSGID: =?utf-8?q?1747825415296942815?= Given a fuzzed object file in an archive with section size exceeding file size, objcopy will report an error like "section size (0xfeffffff bytes) is larger than file size (0x17a bytes)" but will create a copy of the object laid out for the large section. That means a large temporary file on disk that is read back and written to the output archive, which can take a while. The output archive is then deleted due to the error. Avoid some of this silliness. * objcopy.c (copy_section): If section contents cannot be read set output section size to zero. diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 6ffbdf9c681..d20aaef9f4f 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -4418,6 +4418,7 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg) || !bfd_convert_section_contents (ibfd, isection, obfd, &memhunk, &size)) { + bfd_set_section_size (osection, 0); status = 1; bfd_nonfatal_message (NULL, ibfd, isection, NULL); free (memhunk);