git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git Bug Report: out of memory using git tag

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Nov 2, 2022, 00:41 UTC
Message-ID
<38d50c30-c6a3-5989-6e01-47c5467d9d6b@gmail.com>
In-Reply-To
<Y2EPgICMsmzKvCC8@coredump.intra.peff.net>
Hi,
Le 2022-11-01 à 08:22, Jeff King a écrit :
Show 36 quoted lines
> On Fri, Oct 28, 2022 at 03:29:33PM -0700, Martin Englund wrote:
> 
>> What did you do before the bug happened? (Steps to reproduce your issue)
>> I created a signed tag (git tag -s) using a ssh-agent key and then ran
>> git tag -l --format '%(contents:body)' v0.6.1
>>
>> What did you expect to happen? (Expected behavior)
>> I get the output
>>
>> What happened instead? (Actual behavior)
>> fatal: Out of memory, malloc failed (tried to allocate
>> 18446744073709551266 bytes)
> 
> Thanks for the report. This looks like pointer or size_t arithmetic that
> has gone negative. Here's a minimal reproduction:
> 
>   {
>     echo subject
>     echo "-----BEGIN PGP SIGNATURE-----"
>   } | git tag -F - foo
>   git tag -l --format='%(contents:body)' foo
> 
> 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.

Phil.
Previous: Jeff KingNext: Jeff King
Message 3 of 15 in “Git Bug Report: out of memory using git tag”
  1. Martin EnglundOct 28, 2022
  2. Jeff KingNov 1, 2022
  3. Philippe BlainNov 2, 2022
  4. Jeff KingNov 2, 2022
  5. 1/2 ref-filter: fix parsing of signatures without blank linesJeff King, Nov 2, 2022
  6. 2/2 ref-filter: fix parsing of signatures with CRLF and no bodyJeff King, Nov 2, 2022
  7. Elijah NewrenNov 2, 2022
  8. gigantic commit messages, was Re: Git Bug Report: out of memory using git tagJeff King, Nov 2, 2022
  9. Ævar Arnfjörð BjarmasonNov 2, 2022
  10. Elijah NewrenNov 2, 2022
  11. Eric SunshineNov 2, 2022
  12. Philippe BlainNov 2, 2022
  13. Jeff KingNov 3, 2022
  14. Taylor BlauNov 3, 2022
  15. Philippe BlainNov 2, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.