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:
-rw-r--r--patch-delta.c2
-rwxr-xr-xt/t5303-pack-corruption-resilience.sh2
2 files changed, 2 insertions, 2 deletions
diff --git a/patch-delta.c b/patch-delta.c
index 56e0a5ede2..b937afd2c9 100644
--- a/patch-delta.c
+++ b/patch-delta.c
@@ -56,7 +56,7 @@ void *patch_delta(const void *src_buf, unsigned long src_size,
out += cp_size;
size -= cp_size;
} else if (cmd) {
- if (cmd > size)
+ if (cmd > size || cmd > top - data)
break;
memcpy(out, data, cmd);
out += cmd;
diff --git a/t/t5303-pack-corruption-resilience.sh b/t/t5303-pack-corruption-resilience.sh
index 912e659acf..7114c31ade 100755
--- a/t/t5303-pack-corruption-resilience.sh
+++ b/t/t5303-pack-corruption-resilience.sh
@@ -341,7 +341,7 @@ test_expect_success \
# \0 - empty base
# \2 - two bytes in result
# \2 - two literal bytes (we are short one)
-test_expect_failure \
+test_expect_success \
'apply delta with too few literal bytes' \
'printf "\0\2\2X" > truncated_delta &&
test_must_fail test-tool delta -p /dev/null truncated_delta /dev/null'