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

Re: [CRASH] git segfaults on invalid binary diff

From
Jeff King <peff@peff.net>
Date
Oct 18, 2010, 17:40 UTC
Message-ID
<20101018174031.GA9511@sigill.intra.peff.net>
In-Reply-To
<20101018180632.7eb40628@wai>
On Mon, Oct 18, 2010 at 06:06:32PM +0200, Rafaël Carré wrote:
Show 19 quoted lines
> I noticed git crashed on a patch generated with:
> git show --full-index --pretty=email <commit>
> 
> (I had forgotten --binary)
> 
> % git --version
> git version 1.7.3.1.120.g38a18
> % mkdir test
> % cd test
> % git init
> Initialized empty Git repository in /home/fun/test/.git/
> % git am ~/bad.diff
> Applying: foo bar
> Segmentation fault (core dumped)
> Patch failed at 0001 foo bar
> When you have resolved this problem run "git am --resolved".
> If you would prefer to skip this patch, instead run "git am --skip".
> To restore the original branch and stop patching run "git am --abort".
> % cat ~/bad.diff

Hmm, the key seems to be applying it in a new repo without the actual objects. Git will fall back to trying to apply based on the index line, and that is presumably where the bug is. I'll try to work up a patch.

-Peff
Previous: Rafaël CarréNext: Jeff King
Message 2 of 3 in “[CRASH] git segfaults on invalid binary diff”
  1. Rafaël CarréOct 18, 2010
  2. Jeff KingOct 18, 2010
  3. apply: don't segfault on binary files with missing dataJeff King, Oct 18, 2010

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.