From 1deb54c95d508f9adce1dddb073f0b0e4f8e7ba1 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 14 Aug 2021 12:37:02 +0200 Subject: Add a test case for the path traversal bug Signed-off-by: David Oberhollenzer --- tests/Makemodule.am | 7 +++++++ tests/rdsquashfs/pathtraversal.sh.in | 12 ++++++++++++ tests/rdsquashfs/pathtraversal.sqfs | Bin 0 -> 4096 bytes 3 files changed, 19 insertions(+) create mode 100644 tests/rdsquashfs/pathtraversal.sh.in create mode 100644 tests/rdsquashfs/pathtraversal.sqfs (limited to 'tests') diff --git a/tests/Makemodule.am b/tests/Makemodule.am index 8669fb1..3165889 100644 --- a/tests/Makemodule.am +++ b/tests/Makemodule.am @@ -11,7 +11,14 @@ TESTS += tests/cantrbry.sh tests/test_tar_sqfs.sh tests/pack_dir_root.sh endif endif +if WINDOWS +else +check_SCRIPTS += tests/rdsquashfs/pathtraversal.sh +TESTS += tests/rdsquashfs/pathtraversal.sh +endif + EXTRA_DIST += $(top_srcdir)/tests/tar2sqfs EXTRA_DIST += $(top_srcdir)/tests/corpus/cantrbry.tar.xz EXTRA_DIST += $(top_srcdir)/tests/corpus/cantrbry.sha512 EXTRA_DIST += $(top_srcdir)/tests/pack_dir_root.txt.ref +EXTRA_DIST += $(top_srcdir)/tests/rdsquashfs/pathtraversal.sqfs diff --git a/tests/rdsquashfs/pathtraversal.sh.in b/tests/rdsquashfs/pathtraversal.sh.in new file mode 100644 index 0000000..6dd9fab --- /dev/null +++ b/tests/rdsquashfs/pathtraversal.sh.in @@ -0,0 +1,12 @@ +#!/bin/sh + +RDSQFS="@abs_top_builddir@/rdsquashfs" +REFFILE="@abs_top_srcdir@/tests/rdsquashfs/pathtraversal.sqfs" +GOTCHA="/tmp/gotcha.txt" + +if "$RDSQFS" -u / -p . "$REFFILE"; then + if [ -e "$GOTCHA" ]; then + echo "Found $GOTCHA which should not be there" + exit 1 + fi +fi diff --git a/tests/rdsquashfs/pathtraversal.sqfs b/tests/rdsquashfs/pathtraversal.sqfs new file mode 100644 index 0000000..0c33bb3 Binary files /dev/null and b/tests/rdsquashfs/pathtraversal.sqfs differ -- cgit v1.2.3