mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
42612e18d2
Commitf1c0e3946e
(apply: reject patches larger than ~1 GiB, 2022-10-25) added a limit on the size of patch that apply will process to avoid integer overflows. The implementation re-used the existing error message for when we are unable to read the patch. This is unfortunate because (a) it does not signal to the user that the patch is being rejected because it is too large and (b) it uses error_errno() without setting errno. This patch adds a specific error message for the case when a patch is too large. It also updates the existing message to make it clearer that it is the patch that cannot be read rather than any other file and marks both messages for translation. The "git apply" prefix is also dropped to match most of the rest of the error messages in apply.c (there are still a few error messages that prefixed with "git apply" and are not marked for translation after this patch). The test added inf1c0e3946e
is updated accordingly. Reported-by: Premek Vysoky <Premek.Vysoky@microsoft.com> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
24 lines
464 B
Bash
Executable File
24 lines
464 B
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='git apply with too-large patch'
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success EXPENSIVE 'git apply rejects patches that are too large' '
|
|
sz=$((1024 * 1024 * 1023)) &&
|
|
{
|
|
cat <<-\EOF &&
|
|
diff --git a/file b/file
|
|
new file mode 100644
|
|
--- /dev/null
|
|
+++ b/file
|
|
@@ -0,0 +1 @@
|
|
EOF
|
|
test-tool genzeros
|
|
} | test_copy_bytes $sz | test_must_fail git apply 2>err &&
|
|
grep "patch too large" err
|
|
'
|
|
|
|
test_done
|