]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5704-protocol-violations.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t5704-protocol-violations.sh
CommitLineData
4845b772
JK
1#!/bin/sh
2
3test_description='Test responses to violations of the network protocol. In most
4of these cases it will generally be acceptable for one side to break off
5communications if the other side says something unexpected. We are mostly
6making sure that we do not segfault or otherwise behave badly.'
d96fb140
ÆAB
7
8TEST_PASSES_SANITIZE_LEAK=true
4845b772
JK
9. ./test-lib.sh
10
11test_expect_success 'extra delim packet in v2 ls-refs args' '
12 {
13 packetize command=ls-refs &&
4ddd3f50 14 packetize "object-format=$(test_oid algo)" &&
4845b772
JK
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 &&
6789275d 21 test_grep "expected flush after ls-refs arguments" err
4845b772
JK
22'
23
24test_expect_success 'extra delim packet in v2 fetch args' '
25 {
26 packetize command=fetch &&
4ddd3f50 27 packetize "object-format=$(test_oid algo)" &&
4845b772
JK
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 &&
6789275d 34 test_grep "expected flush after fetch arguments" err
4845b772
JK
35'
36
44d2aec6
AH
37test_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
4845b772 52test_done