From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 068631F910 for ; Wed, 2 Nov 2022 07:39:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbiKBHj0 (ORCPT ); Wed, 2 Nov 2022 03:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbiKBHjY (ORCPT ); Wed, 2 Nov 2022 03:39:24 -0400 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DB1310E6 for ; Wed, 2 Nov 2022 00:39:22 -0700 (PDT) Received: (qmail 8920 invoked by uid 109); 2 Nov 2022 07:39:21 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 02 Nov 2022 07:39:21 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 2803 invoked by uid 111); 2 Nov 2022 07:39:23 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 02 Nov 2022 03:39:23 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 2 Nov 2022 03:39:20 -0400 From: Jeff King To: Philippe Blain Cc: Martin Englund , git@vger.kernel.org Subject: Re: Git Bug Report: out of memory using git tag Message-ID: References: <38d50c30-c6a3-5989-6e01-47c5467d9d6b@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <38d50c30-c6a3-5989-6e01-47c5467d9d6b@gmail.com> Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Tue, Nov 01, 2022 at 08:41:55PM -0400, Philippe Blain wrote: > > The issue isn't unique to pgp signatures; the problem is in the parsing > > done by ref-filter's find_subpos(), so any signature type exhibits the > > problem. At the end of that function we do: > > > > *nonsiglen = sigstart - buf; > > > > but "buf" has moved beyond "sigstart". Presumably because it uses > > strstr() to look for end-of-line in buf. Since there isn't one before > > the signature begins, we go to the end of the signature. > > > > The bug bisects to 9f75ce3d8f (ref-filter: handle CRLF at end-of-line > > more gracefully, 2020-10-29). Before then, I think our loop was careful > > about moving past the start of the signature. Author cc'd. > > > > Thanks for letting me know, and for the simple reproducer, that's very useful. > I'll try to find time to fix that this week, but can't promise anything. After sleeping on it, I think I fully understand what's going on. There are actually _two_ bugs, but they are closely related. ;) Here are patches which fix them both. I may be setting a new record for the ratio of commit message lines to changed code. But it took me a while to figure out what was going on, so I wanted to explain it fully. [1/2]: ref-filter: fix parsing of signatures without blank lines [2/2]: ref-filter: fix parsing of signatures with CRLF and no body ref-filter.c | 8 ++++---- t/t6300-for-each-ref.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) -Peff