From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Lars Schneider <larsxschneider@gmail.com>,
Git List <git@vger.kernel.org>
Subject: Re: SHA1 collision in production repo?! (probably not)
Date: Fri, 31 Mar 2017 11:19:54 -0700 [thread overview]
Message-ID: <xmqq4ly9z4tx.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170331174827.zheqstwtlsqtxa6e@sigill.intra.peff.net> (Jeff King's message of "Fri, 31 Mar 2017 13:48:27 -0400")
Jeff King <peff@peff.net> writes:
> On Fri, Mar 31, 2017 at 01:45:15PM -0400, Jeff King wrote:
>
>> I suspect this may improve things, but I haven't dug deeper to see if
>> there are unwanted side effects, or if there are other spots that need
>> similar treatment.
>>
>> diff --git a/sha1_file.c b/sha1_file.c
>> index 43990dec7..38411f90b 100644
>> --- a/sha1_file.c
>> +++ b/sha1_file.c
>> @@ -2952,7 +2952,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,
>> if (status && oi->typep)
>> *oi->typep = status;
>> strbuf_release(&hdrbuf);
>> - return 0;
>> + return status;
>> }
>>
>> int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi, unsigned flags)
>
> Er, no, that's totally wrong. "status' may be holding the type. It
> should really be:
>
> return status < 0 ? status : 0;
Sounds more like it. The only caller will say "ah, that object is
not available to us---let's try packs again", which is exactly what
we want to happen.
There is another bug in the codepath: the assignment to *oi->typep
in the pre-context must guard against negative status value. By
returning an error correctly like you do above, that bug becomes
more or less irrelevant, though.
next prev parent reply other threads:[~2017-03-31 18:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-31 16:05 SHA1 collision in production repo?! (probably not) Lars Schneider
2017-03-31 17:27 ` Jeff King
2017-03-31 17:35 ` Junio C Hamano
2017-03-31 17:45 ` Jeff King
2017-03-31 17:48 ` Jeff King
2017-03-31 18:19 ` Junio C Hamano [this message]
2017-03-31 18:42 ` Jeff King
2017-03-31 21:16 ` Junio C Hamano
2017-04-01 8:03 ` Jeff King
2017-04-01 8:05 ` [PATCH 1/2] sha1_loose_object_info: return error for corrupted objects Jeff King
2017-04-01 17:47 ` Junio C Hamano
2017-04-01 8:09 ` [PATCH 2/2] index-pack: detect local corruption in collision check Jeff King
2017-04-01 18:04 ` Junio C Hamano
2017-09-12 16:18 ` SHA1 collision in production repo?! (probably not) Lars Schneider
2017-09-12 17:38 ` Jeff King
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq4ly9z4tx.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=larsxschneider@gmail.com \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).