From: Jeff King <peff@peff.net>
To: Markus Heidelberg <markus.heidelberg@web.de>
Cc: Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org, Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: Re: [PATCH] sha1_name: fix segfault caused by invalid index access
Date: Sun, 28 Feb 2010 11:25:50 -0500 [thread overview]
Message-ID: <20100228162550.GA7315@coredump.intra.peff.net> (raw)
In-Reply-To: <1267372155-7578-1-git-send-email-markus.heidelberg@web.de>
On Sun, Feb 28, 2010 at 04:49:15PM +0100, Markus Heidelberg wrote:
> It can be reproduced in a bare repository with
> $ git show :anyfile
>
> I didn't find a recipe for reliably reproducing it in a repository with
> working tree, it happened depending on the filename and the repository.
> $ git show :nonexistentfile
I can confirm the bug here. It is not about bareness, but having no
index makes it easy to trigger, since it is easy to walk past the end of
a zero-length index. But it is not restricted to that case:
> It seemed to happen more likely with high letters (x, y, z) as the first
> character of the filename. This always worked for me:
> $ git show :z
> But I found this to be too strange to be added to the commit message.
That's because cache_name_pos returns the position where the entry
_would_ be if it existed (well, the negation minus one, but the intent
is you can reconstruct that position if you did want to insert it). The
diagnose_invalid function then looks at that entry to see if it is a
missing filename or a missing stage. But of course, if it would be
inserted past the end of what exists in the index, there is nothing to
look at. So your ":z" is simply about being at the end of the index,
which is sorted alphabetically.
Which means your fix (to make sure we are not at the end) is correct.
-Peff
prev parent reply other threads:[~2010-02-28 16:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-28 15:49 [PATCH] sha1_name: fix segfault caused by invalid index access Markus Heidelberg
2010-02-28 16:20 ` Matthieu Moy
2010-02-28 16:38 ` Matthieu Moy
2010-02-28 18:13 ` Junio C Hamano
2010-02-28 16:25 ` Jeff King [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100228162550.GA7315@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=Matthieu.Moy@imag.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=markus.heidelberg@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).