From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Sixt <j6t@kdbg.org>,
git@vger.kernel.org, Jacek Wielemborek <d33tah@gmail.com>
Subject: Re: [PATCH 1/3] t5313: test bounds-checks of corrupted/malicious pack/idx files
Date: Thu, 25 Feb 2016 17:07:24 -0500 [thread overview]
Message-ID: <20160225220724.GB10267@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqq4mcwo7lb.fsf@gitster.mtv.corp.google.com>
On Thu, Feb 25, 2016 at 12:31:12PM -0800, Junio C Hamano wrote:
> Johannes Sixt <j6t@kdbg.org> writes:
>
> > Am 25.02.2016 um 15:21 schrieb Jeff King:
> >> +munge () {
> >> + printf "$3" | dd of="$1" bs=1 conv=notrunc seek=$2
> >> +}
> >
> > Instead of adding another call of dd, would it be an option to insert
> > the following patch at the front of this series and then use
> > test_overwrite_bytes?
>
> It would be an option, but I'd want to merge this to 'next' today
> without waiting for a reroll. Change from dd to custom script can
> be done as a follow-up topic after the dust settles, if necessary.
That's fine with me, and in general I am fine with the conversion from
dd to perl. I have to look up the dd command line options each time
anyway (was it "skip" or "seek"...?). ;)
But note that the use of "dd" in the "bogus offset inside extended
table" test in my patch is different from the others. It copies a set
amount of bytes, and inserts some custom data, and then copies more.
I think you could replace the first with "head -c", and the latter with
"tail -c". In the latter you'd have to compute the distance from the end
rather than the seek offset, but we know that already: it's 20 + 20 for
the trailing sha1s. Like this, I think:
diff --git a/t/t5313-pack-bounds-checks.sh b/t/t5313-pack-bounds-checks.sh
index a8a587a..20bc0a3 100755
--- a/t/t5313-pack-bounds-checks.sh
+++ b/t/t5313-pack-bounds-checks.sh
@@ -144,10 +144,10 @@ test_expect_success 'bogus offset inside v2 extended table' '
# We have to make extra room for the table, so we cannot
# just munge in place as usual.
{
- dd if=$idx bs=1 count=$(($(ofs_table 2) + 4)) &&
+ head -c $(($(ofs_table 2) + 4)) $idx &&
printf "\200\0\0\0" &&
printf "\377\0\0\0\0\0\0\0" &&
- dd if=$idx bs=1 skip=$(extended_table 2)
+ tail -c 40 $idx
} >tmp &&
mv tmp "$idx" &&
clear_base &&
next prev parent reply other threads:[~2016-02-25 22:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-25 14:20 [PATCH 0/3] out-of-bounds access from corrupted .idx files Jeff King
2016-02-25 14:21 ` [PATCH 1/3] t5313: test bounds-checks of corrupted/malicious pack/idx files Jeff King
2016-02-25 19:12 ` Johannes Sixt
2016-02-25 20:31 ` Junio C Hamano
2016-02-25 22:07 ` Jeff King [this message]
2016-02-25 14:22 ` [PATCH 2/3] nth_packed_object_offset: bounds-check extended offset Jeff King
2016-02-25 14:23 ` [PATCH 3/3] use_pack: handle signed off_t overflow Jeff King
2016-02-27 7:49 ` [PATCH 4/3] sha1_file.c: mark strings for translation Nguyễn Thái Ngọc Duy
2016-02-27 17:41 ` Junio C Hamano
2016-02-27 18:25 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160225220724.GB10267@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=d33tah@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.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.
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).