git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 0/3] validate_headref: avoid reading uninitialized bytes
Date: Wed, 27 Sep 2017 02:16:45 -0400	[thread overview]
Message-ID: <20170927061644.gwlhxaiairiy2njp@sigill.intra.peff.net> (raw)

While looking at read_in_full() callers for a nearby patch series, I
noticed this fairly harmless bug. The first patch fixes it, and the
other two do some cleanups on top.

I'm tempted to say the whole thing ought to just use a strbuf. We
typically only call this function once per program, and git HEAD files
are small enough not to worry about. On the other hand, the point of the
function is to see if this is in fact a git repository. So in the rare
case that we see a file named ".git/HEAD" that's actually a 2GB video
file, we'd prefer to find out after reading only 256 bytes, not the
whole thing.

  [1/3]: validate_headref: NUL-terminate HEAD buffer
  [2/3]: validate_headref: use skip_prefix for symref parsing
  [3/3]: validate_headref: use get_oid_hex for detached HEADs

 path.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

-Peff

             reply	other threads:[~2017-09-27  6:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-27  6:16 Jeff King [this message]
2017-09-27  6:17 ` [PATCH 1/3] validate_headref: NUL-terminate HEAD buffer Jeff King
2017-09-27  7:06   ` Junio C Hamano
2017-09-27  7:16     ` Jeff King
2017-09-27  7:28       ` Junio C Hamano
2017-09-27  6:17 ` [PATCH 2/3] validate_headref: use skip_prefix for symref parsing Jeff King
2017-09-27  7:07   ` Junio C Hamano
2017-09-27  6:17 ` [PATCH 3/3] validate_headref: use get_oid_hex for detached HEADs 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=20170927061644.gwlhxaiairiy2njp@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    /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).