Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [RFC] t5300 considered dangerous
Date: Mon, 26 Dec 2005 18:10:21 -0800	[thread overview]
Message-ID: <7vd5jjffxu.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: Pine.LNX.4.63.0512270018310.3067@wbgn013.biozentrum.uni-wuerzburg.de

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> The test case corrupts a pack, and then also the index of that pack, by 
> writing "0" at certain offsets, and then tests if git-verify-pack fails.

These certain offsets are:

 . byte    2 in pack
   This corrupts PACK_SIGNATURE ("A" in "PACK").

 . byte    7 in pack
   This corrupts PACK_VERSION ("\002" in "\0\0\0\002").

 . byte   12 in pack
   This corrupts the type/size byte of whatever the first object
   happens to be (the type/size byte has non-zero upper nibble).

 . byte 1200 in idx that is currently 1208 bytes long.
   This tries to corrupt the checksum of the index file itself,

You are right about the last one; this location has 1/256 chance
of validly being 0, and making the set of objects to be packed
constant is one way to fix it.  More appropriate way would be to
measure how long the .idx file is, and corrupt the last 20 bytes;
I was too lazy.

-- >8 --

diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index 7dfb1ab..dd719bb 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -163,8 +163,10 @@ test_expect_success \
      else :;
      fi &&
 
+     l=`wc -c <test-3.idx` &&
+     l=`expr "$l" - 20` &&
      cp test-1-${packname_1}.pack test-3.pack &&
-     dd if=/dev/zero of=test-3.idx count=1 bs=1 conv=notrunc seek=1200 &&
+     dd if=/dev/zero of=test-3.idx count=20 bs=1 conv=notrunc seek=$l &&
      if git-verify-pack test-3.pack
      then false
      else :;

  parent reply	other threads:[~2005-12-27  2:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-26 23:35 [RFC] t5500 considered dangerous Johannes Schindelin
2005-12-26 23:37 ` Johannes Schindelin
2005-12-27  2:10 ` Junio C Hamano [this message]
2005-12-27 13:57   ` [RFC] t5300 " Johannes Schindelin
2005-12-27 14:08     ` 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=7vd5jjffxu.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=Johannes.Schindelin@gmx.de \
    --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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox