git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Morten Welinder <mwelinder@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: diff_tree_stdin
Date: Thu, 13 Oct 2005 00:11:07 -0700	[thread overview]
Message-ID: <7vu0fl51tg.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <118833cc0510111846q42c5d7e5j162bdacd49dfebbc@mail.gmail.com> (Morten Welinder's message of "Tue, 11 Oct 2005 21:46:38 -0400")

Morten Welinder <mwelinder@gmail.com> writes:

> It looks like diff_tree_stdin can overrun the this_header buffer.  Since the
> line length is already calculated, a check would be cheap.

I presume you are talking about "line", not this_header[], since
you are talking about something whose length is already
calculated.

The output buffer this_header[] only ever gets two 40-byte SHA1
and a handful more, so probably 128 bytes would be big enough --
the current 1000 is overkill.

The input line[] is first NUL terminated before getting scanned,
and scanning with get_sha1_hex() stops immediately when we see
NUL, and premature NUL makes it fail, so the first
get_sha1_hex() would not overrun.  If the first SHA1 is followed
by garbage then the second get_sha1_hex() would not succeed
without overrunning either.  If line[40] is NUL then we do not
even do the second get_sha1_hex() --- in any case I do not see
overrun.

I am getting tired (it _was_ my GIT day, but unfortunately I had
to be worried about another day-job project during the day X-<),
and I might probably be overlooking something fairly obvious to
you.  Care to explain?

  reply	other threads:[~2005-10-13  7:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-12  1:46 diff_tree_stdin Morten Welinder
2005-10-13  7:11 ` Junio C Hamano [this message]
2005-10-13 15:01   ` diff_tree_stdin Morten Welinder

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=7vu0fl51tg.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=mwelinder@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).