diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2012-09-17 15:25:25 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruen@linbit.com> | 2012-09-17 15:48:06 +0200 |
commit | 20c9d7d5abc41d5a2c6cfed9fe69654ae9a3a4f6 (patch) | |
tree | fd19325e0d8165438c67b2cdd3ffb56768e7ffa2 /tests | |
parent | 2b2fb1f36c4d0662dc2340c57a8a9b084ea861c8 (diff) | |
download | patch-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-filenames | 11 |
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 |