diff --git a/tests/functional/dot.nar b/tests/functional/dot.nar new file mode 100644 index 000000000..3a9452f67 Binary files /dev/null and b/tests/functional/dot.nar differ diff --git a/tests/functional/dotdot.nar b/tests/functional/dotdot.nar new file mode 100644 index 000000000..f8d019c39 Binary files /dev/null and b/tests/functional/dotdot.nar differ diff --git a/tests/functional/empty.nar b/tests/functional/empty.nar new file mode 100644 index 000000000..43434f2b4 Binary files /dev/null and b/tests/functional/empty.nar differ diff --git a/tests/functional/nars.sh b/tests/functional/nars.sh index 9f5f43dc6..68b9b45d9 100755 --- a/tests/functional/nars.sh +++ b/tests/functional/nars.sh @@ -92,3 +92,23 @@ else [[ -e $TEST_ROOT/out/â ]] [[ -e $TEST_ROOT/out/â ]] fi + +# Unpacking a NAR with a NUL character in a file name should fail. +rm -rf "$TEST_ROOT/out" +expectStderr 1 nix-store --restore "$TEST_ROOT/out" < nul.nar | grepQuiet "NAR contains invalid file name 'f" + +# Likewise for a '.' filename. +rm -rf "$TEST_ROOT/out" +expectStderr 1 nix-store --restore "$TEST_ROOT/out" < dot.nar | grepQuiet "NAR contains invalid file name '.'" + +# Likewise for a '..' filename. +rm -rf "$TEST_ROOT/out" +expectStderr 1 nix-store --restore "$TEST_ROOT/out" < dotdot.nar | grepQuiet "NAR contains invalid file name '..'" + +# Likewise for a filename containing a slash. +rm -rf "$TEST_ROOT/out" +expectStderr 1 nix-store --restore "$TEST_ROOT/out" < slash.nar | grepQuiet "NAR contains invalid file name 'x/y'" + +# Likewise for an empty filename. +rm -rf "$TEST_ROOT/out" +expectStderr 1 nix-store --restore "$TEST_ROOT/out" < empty.nar | grepQuiet "NAR contains invalid file name ''" diff --git a/tests/functional/nul.nar b/tests/functional/nul.nar new file mode 100644 index 000000000..9ae48baf6 Binary files /dev/null and b/tests/functional/nul.nar differ diff --git a/tests/functional/slash.nar b/tests/functional/slash.nar new file mode 100644 index 000000000..118a60216 Binary files /dev/null and b/tests/functional/slash.nar differ