Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2020-08-02 01:06:11 +0300
committerJunio C Hamano <gitster@pobox.com>2020-08-02 03:46:42 +0300
commitdc156bc31f6a992599cd5c35af27026c39fcbf77 (patch)
tree92bc16c323f405a6f75fa3cc9a805942d3da38ee /t/t1450-fsck.sh
parentb3d7a52fac39193503a0b6728771d1bf6a161464 (diff)
t1450: fix quoting of NUL byte when corrupting pack
We use printf '\0' to generate a NUL byte which we then `dd` into the packfile to ensure that we modify the first byte of the first object, thereby (probabilistically) invalidating the checksum. Except the single quotes we're using are interpreted to match with the ones we enclose the whole test in. So we actually execute printf \0 and end up injecting the ASCII code for "0", 0x30, instead. The comment right above this `printf` invocation says that "at least one of [the type bits] is not zero, so setting the first byte to 0 is sufficient". Substituting "0x30" for "0" in that comment won't do: we'd need to reason about which bits go where and just what the packfile looks like that we're modifying in this test. Let's avoid all of that by actually executing printf "\0" to generate a NUL byte, as intended. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1450-fsck.sh')
-rwxr-xr-xt/t1450-fsck.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 91a6e34f38..45fe4eb857 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -701,7 +701,7 @@ test_expect_success 'fsck fails on corrupt packfile' '
# at least one of which is not zero, so setting the first byte to 0 is
# sufficient.)
chmod a+w .git/objects/pack/pack-$pack.pack &&
- printf '\0' | dd of=.git/objects/pack/pack-$pack.pack bs=1 conv=notrunc seek=12 &&
+ printf "\0" | dd of=.git/objects/pack/pack-$pack.pack bs=1 conv=notrunc seek=12 &&
test_when_finished "rm -f .git/objects/pack/pack-$pack.*" &&
remove_object $hsh &&