From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: Thomas Rast <trast@student.ethz.ch>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 2/2] Make hash-object more robust against malformed objects
Date: Sat, 12 Feb 2011 21:47:06 +0700 [thread overview]
Message-ID: <20110212144706.GA25124@do> (raw)
In-Reply-To: <201102121242.21339.trast@student.ethz.ch>
On Sat, Feb 12, 2011 at 12:42:21PM +0100, Thomas Rast wrote:
> This patch makes t9350 fail under valgrind:
>
> expecting success:
>
> TAG=$(git hash-object -t tag -w tag-content) &&
> git update-ref refs/tags/sonnenschein $TAG &&
> git fast-export -C -C --signed-tags=strip --all > output &&
> test $(grep -c "^tag " output) = 4 &&
> ! grep "Unspecified Tagger" output &&
> git fast-export -C -C --signed-tags=strip --all \
> --fake-missing-tagger > output &&
> test $(grep -c "^tag " output) = 4 &&
> grep "Unspecified Tagger" output
>
>
> ==2862== Invalid read of size 1
> ==2862== at 0x4F0C34: prefixcmp (strbuf.c:9)
> ==2862== by 0x4F4FB3: parse_tag_buffer (tag.c:109)
Nice. Does this fix it?
--8<--
diff --git a/tag.c b/tag.c
index ecf7c1e..9318ae5 100644
--- a/tag.c
+++ b/tag.c
@@ -97,7 +97,9 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
item->tagged = NULL;
}
- if (prefixcmp(bufptr, "tag "))
+ if (bufptr + 5 < tail && !prefixcmp(bufptr, "tag "))
+ ; /* good */
+ else
return -1;
bufptr += 4;
nl = memchr(bufptr, '\n', tail - bufptr);
@@ -106,7 +108,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
item->tag = xmemdupz(bufptr, nl - bufptr);
bufptr = nl + 1;
- if (!prefixcmp(bufptr, "tagger "))
+ if (bufptr + 8 < tail && !prefixcmp(bufptr, "tagger "))
item->date = parse_tag_date(bufptr, tail);
else
item->date = 0;
--8<--
--
Duy
next prev parent reply other threads:[~2011-02-12 14:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-05 10:52 [PATCH 1/2] Add const to parse_{commit,tag}_buffer() Nguyễn Thái Ngọc Duy
2011-02-05 10:52 ` [PATCH 2/2] Make hash-object more robust against malformed objects Nguyễn Thái Ngọc Duy
2011-02-12 11:42 ` Thomas Rast
2011-02-12 14:47 ` Nguyen Thai Ngoc Duy [this message]
2011-02-14 13:02 ` [PATCH] parse_tag_buffer(): do not prefixcmp() out of range Nguyễn Thái Ngọc Duy
2011-02-15 21:18 ` Junio C Hamano
2011-02-16 3:39 ` Nguyen Thai Ngoc Duy
2011-02-17 12:43 ` René Scharfe
2011-02-18 12:49 ` [PATCH] parse_tag_buffer(): avoid out of bound access Nguyễn Thái Ngọc Duy
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=20110212144706.GA25124@do \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=trast@student.ethz.ch \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.