]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5704-protocol-violations.sh
The third batch
[thirdparty/git.git] / t / t5704-protocol-violations.sh
1 #!/bin/sh
2
3 test_description='Test responses to violations of the network protocol. In most
4 of these cases it will generally be acceptable for one side to break off
5 communications if the other side says something unexpected. We are mostly
6 making sure that we do not segfault or otherwise behave badly.'
7
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
11 test_expect_success 'extra delim packet in v2 ls-refs args' '
12 {
13 packetize command=ls-refs &&
14 packetize "object-format=$(test_oid algo)" &&
15 printf 0001 &&
16 # protocol expects 0000 flush here
17 printf 0001
18 } >input &&
19 test_must_fail env GIT_PROTOCOL=version=2 \
20 git upload-pack . <input 2>err &&
21 test_grep "expected flush after ls-refs arguments" err
22 '
23
24 test_expect_success 'extra delim packet in v2 fetch args' '
25 {
26 packetize command=fetch &&
27 packetize "object-format=$(test_oid algo)" &&
28 printf 0001 &&
29 # protocol expects 0000 flush here
30 printf 0001
31 } >input &&
32 test_must_fail env GIT_PROTOCOL=version=2 \
33 git upload-pack . <input 2>err &&
34 test_grep "expected flush after fetch arguments" err
35 '
36
37 test_expect_success 'bogus symref in v0 capabilities' '
38 test_commit foo &&
39 oid=$(git rev-parse HEAD) &&
40 dst=refs/heads/foo &&
41 {
42 printf "%s HEAD\0symref object-format=%s symref=HEAD:%s\n" \
43 "$oid" "$GIT_DEFAULT_HASH" "$dst" |
44 test-tool pkt-line pack-raw-stdin &&
45 printf "0000"
46 } >input &&
47 git ls-remote --symref --upload-pack="cat input; read junk;:" . >actual &&
48 printf "ref: %s\tHEAD\n%s\tHEAD\n" "$dst" "$oid" >expect &&
49 test_cmp expect actual
50 '
51
52 test_done