summaryrefslogtreecommitdiff
path: root/tests/bad-filenames
blob: f53a61368360e1ab5e121db8ab4260fe5828585e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copyright (C) 2011 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# in any medium, are permitted without royalty provided the copyright
# notice and this notice are preserved.

. $srcdir/test-lib.sh

use_local_patch

# ================================================================

emit_patch()
{
cat <<EOF
--- /dev/null
+++ $1
@@ -0,0 +1 @@
+x
EOF
}

# Ensure that patch rejects an output file name that is absolute
# or that contains a ".." component.

check 'emit_patch /absolute/path | patch -p0; echo status: $?' <<EOF
$PATCH: **** rejecting absolute file name: /absolute/path
status: 2
EOF

check 'emit_patch a/../z | patch -p0; echo status: $?' <<EOF
$PATCH: **** rejecting file name with ".." component: a/../z
status: 2
EOF

check 'emit_patch a/../z | patch -p1; echo status: $?' <<EOF
$PATCH: **** rejecting file name with ".." component: ../z
status: 2
EOF

check 'emit_patch a/.. | patch -p0; echo status: $?' <<EOF
$PATCH: **** rejecting file name with ".." component: a/..
status: 2
EOF

check 'emit_patch ../z | patch -p0; echo status: $?' <<EOF
$PATCH: **** rejecting file name with ".." component: ../z
status: 2
EOF