Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t4141-apply-too-large.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t4141-apply-too-large.sh` 71 lines ยท 1862 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='git apply with too-large patch' 4 5 . ./test-lib.sh 6 7 test_expect_success EXPENSIVE 'git apply rejects patches that are too large' ' 8 { 9 cat <<-\EOF && 10 diff --git a/file b/file 11 new file mode 100644 12 --- /dev/null 13 +++ b/file 14 @@ -0,0 +1 @@ 15 EOF 16 test-tool genzeros $((1024 * 1024 * 1023)) 17 } | test_must_fail git apply 2>err && 18 test_grep "patch too large" err 19 ' 20 21 test_expect_success EXPENSIVE 'git apply rejects binary patches that are too large' ' 22 sz=$((1024 * 1024 * 2048)) && 23 test-tool genzeros $sz | test-tool zlib deflate | test-tool base85 chunk-encode >payload && 24 { 25 # Although the patch requires the correct blob ID, blob ID validation 26 # happens after the inflated content size check, so use $EMPTY_BLOB as 27 # a filler. 28 cat <<-EOF && 29 diff --git a/file b/file 30 new file mode 100644 31 index $ZERO_OID..$EMPTY_BLOB 32 GIT binary patch 33 literal $sz 34 EOF 35 cat payload 36 } | test_must_fail git apply 2>err && 37 test_grep "patch too large" err 38 ' 39 40 test_expect_success EXPENSIVE 'git apply rejects large binary patches with incorrect size' ' 41 sz=$((1024 * 1024 * 1023)) && 42 test-tool genrandom foo $sz | test-tool zlib deflate | test-tool base85 chunk-encode >payload && 43 { 44 cat <<-EOF && 45 diff --git a/file b/file 46 new file mode 100644 47 index $ZERO_OID..$EMPTY_BLOB 48 GIT binary patch 49 literal 10 50 EOF 51 cat payload 52 } | test_must_fail git apply 2>err && 53 test_grep "patch too large" err 54 ' 55 56 test_expect_success 'git apply rejects binary patches with incorrect size' ' 57 test-tool genrandom foo 100 | test-tool zlib deflate | test-tool base85 chunk-encode >payload && 58 { 59 cat <<-EOF && 60 diff --git a/file b/file 61 new file mode 100644 62 index $ZERO_OID..$EMPTY_BLOB 63 GIT binary patch 64 literal 10 65 EOF 66 cat payload 67 } | test_must_fail git apply 2>err && 68 test_grep "corrupt binary patch" err 69 ' 70 71 test_done