summaryrefslogtreecommitdiff
path: root/t/t5303-pack-corruption-resilience.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-08-30 07:12:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-30 17:30:23 (GMT)
commit9514b0b22624b9a6de80a480ab480d61ce29833b (patch)
tree7a3928743960beb407c2d8ae13e81d64bfbcd7c0 /t/t5303-pack-corruption-resilience.sh
parentfa72f90e7a5cfbbc32860c6336628c96791b5af3 (diff)
downloadgit-9514b0b22624b9a6de80a480ab480d61ce29833b.zip
git-9514b0b22624b9a6de80a480ab480d61ce29833b.tar.gz
git-9514b0b22624b9a6de80a480ab480d61ce29833b.tar.bz2
patch-delta: handle truncated copy parameters
When we see a delta command instructing us to copy bytes from the base, we have to read the offset and size from the delta stream. We do this without checking whether we're at the end of the stream, meaning we may read past the end of the buffer. In practice this isn't exploitable in any interesting way because: 1. Deltas are always in packfiles, so we have at least a 20-byte trailer that we'll end up reading. 2. The worst case is that we try to perform a nonsense copy from the base object into the result, based on whatever was in the pack stream next. In most cases this will simply fail due to our bounds-checks against the base or the result. But even if you carefully constructed a pack stream for which it succeeds, it wouldn't perform any delta operation that you couldn't have simply included in a non-broken form. But obviously it's poor form to read past the end of the buffer we've been given. Unfortunately there's no easy way to do a single length check, since the number of bytes we need depends on the number of bits set in the initial command byte. So we'll just check each byte as we parse. We can hide the complexity in a macro; it's ugly, but not as ugly as writing out each individual conditional. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Nicolas Pitre <nico@fluxnic.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5303-pack-corruption-resilience.sh')
-rwxr-xr-xt/t5303-pack-corruption-resilience.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/t/t5303-pack-corruption-resilience.sh b/t/t5303-pack-corruption-resilience.sh
index 41dc947..b68bbee 100755
--- a/t/t5303-pack-corruption-resilience.sh
+++ b/t/t5303-pack-corruption-resilience.sh
@@ -364,7 +364,7 @@ test_expect_success \
#
# Note that the literal byte is necessary to get past the uninteresting minimum
# delta size check.
-test_expect_failure \
+test_expect_success \
'apply delta with truncated copy parameters' \
'printf "\5\5\1X\221" > truncated_copy_delta &&
echo base >base &&