summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@linbit.com>2012-09-17 15:25:25 +0200
committerAndreas Gruenbacher <agruen@linbit.com>2012-09-17 15:48:06 +0200
commit20c9d7d5abc41d5a2c6cfed9fe69654ae9a3a4f6 (patch)
treefd19325e0d8165438c67b2cdd3ffb56768e7ffa2 /tests
parent2b2fb1f36c4d0662dc2340c57a8a9b084ea861c8 (diff)
downloadpatch-20c9d7d5abc41d5a2c6cfed9fe69654ae9a3a4f6.tar.gz
Allow to use potentially dangerous filenames from the root directory
* src/pch.c (cwd_is_root): New function to check if we are in the root directory of a filename. (name_is_valid): Allow to use potentially dangerous filenames when the current working directory is the root directory: from there, those names are not any more dangerous than other names. * tests/bad-filenames: New test case.
Diffstat (limited to 'tests')
-rw-r--r--tests/bad-filenames11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/bad-filenames b/tests/bad-filenames
index 5b4f205..121cfda 100644
--- a/tests/bad-filenames
+++ b/tests/bad-filenames
@@ -42,6 +42,17 @@ No file to patch. Skipping patch.
status: 1
EOF
+for dir in "$TMPDIR" "$TMP" "$TEMP" "/tmp"; do
+ if test -n "$dir"; then
+ filename=$dir/patch-$$-$RANDOM
+ break
+ fi
+done
+
+check 'emit_patch $filename | (cd / && patch -f -p0 --dry-run) || echo status: $?' <<EOF
+patching file $filename
+EOF
+
check 'emit_patch a/../z | patch -f -p0 --dry-run || echo status: $?' <<EOF
Ignoring potentially dangerous file name a/../z
can't find file to patch at input line 3