From: Jeff King <peff@peff.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Duy Nguyen <pclouds@gmail.com>,
Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org
Subject: Re: [PATCH] fsck: properly bound "invalid tag name" error message
Date: Mon, 8 Dec 2014 06:47:40 -0500 [thread overview]
Message-ID: <20141208114740.GA16658@peff.net> (raw)
In-Reply-To: <alpine.DEB.1.00.1412081232500.13845@s15462909.onlinehome-server.info>
On Mon, Dec 08, 2014 at 12:35:27PM +0100, Johannes Schindelin wrote:
> On Mon, 8 Dec 2014, Duy Nguyen wrote:
>
> > On Mon, Dec 08, 2014 at 12:57:06AM -0500, Jeff King wrote:
> > > I do admit that I am tempted to teach index-pack to always NUL-terminate
> > > objects in memory that we feed to fsck, just to be on the safe side. It
> > > doesn't cost much, and could prevent a silly mistake (either in the
> > > future, or one that I missed in my analysis).
> >
> > I think I'm missing a "but.." here.
>
> The "but..."s I have are:
>
> 1) we potentially waste space, and
I think this can be ignored. It's 1 byte per object, and only while we
keep the object in RAM. Also, we already do it for buffers read from
read_sha1_file, so when you run "git log" every commit buffer we keep in
RAM is already doing this (and has been since basically day one).
> 2) I would like to make really certain, preferably with static analysis,
> that fsck_object() only receives buffers that are NUL terminated, and
> that no call path is missed.
I know this is not as good as a real static analysis, but I was
concerned about this exact thing about a year ago (I think in relation
to commit parsing for pretty-printing) and traced all of the paths
through which you can get an object; they all end up in the same few
code paths that all xmallocz: unpack_sha1_file for loose objects,
unpack_compressed_entry for pack bases, and patch_delta for deltas.
Index-pack and unpack-objects are the odd men out here because they are
processing objects that are not actually in the repository yet. I think
the spots Duy pointed out probably cover index-pack. It looks like
builtin/unpack-objects.c:get_data needs the same treatment.
I know that Duy mentioned a while ago killing off unpack-objects and
rolling its functionality into index-pack. That would be a very nice
thing to do if somebody can find the time. There's a fair bit of
duplication, and index-pack receives a lot more attention (so it's
faster, and probably more robust against weird incoming packs).
-Peff
next prev parent reply other threads:[~2014-12-08 11:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-08 5:48 [PATCH] fsck: properly bound "invalid tag name" error message Jeff King
2014-12-08 5:57 ` Jeff King
2014-12-08 11:17 ` Johannes Schindelin
2014-12-08 11:22 ` Jeff King
2014-12-08 11:28 ` Duy Nguyen
2014-12-08 11:35 ` Johannes Schindelin
2014-12-08 11:47 ` Jeff King [this message]
2014-12-08 13:46 ` Johannes Schindelin
2014-12-08 14:17 ` [PATCH v2] index-pack: terminate object buffers with NUL Johannes Schindelin
2014-12-08 11:01 ` [PATCH] fsck: properly bound "invalid tag name" error message Johannes Schindelin
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=20141208114740.GA16658@peff.net \
--to=peff@peff.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
/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).