aboutsummaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-11-19 17:17:48 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-11-19 17:17:48 +0100
commit0545e3b69ab57af1c21d199611c56b7f7593c8c5 (patch)
treee085c0df969e977e3a6f1b247759d40eacf57129 /testsuite
parentdd1d8ab506420014cf0a3a076b2e3a4fa5de16ee (diff)
downloadbusybox-0545e3b69ab57af1c21d199611c56b7f7593c8c5.tar.gz
tar: prevent empty file to be treated as valid tarball
function old new delta tar_main 879 895 +16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/tar.tests25
1 files changed, 25 insertions, 0 deletions
diff --git a/testsuite/tar.tests b/testsuite/tar.tests
index c947d3382..93ba5f004 100755
--- a/testsuite/tar.tests
+++ b/testsuite/tar.tests
@@ -15,6 +15,15 @@ mkdir tar.tempdir && cd tar.tempdir || exit 1
# testing "test name" "script" "expected result" "file input" "stdin"
+testing "Empty file is not a tarball" '\
+tar xvf - 2>&1; echo $?
+' "\
+tar: short read
+1
+" \
+"" ""
+SKIP=
+
optional FEATURE_SEAMLESS_GZ
testing "Empty file is not a tarball.tar.gz" '\
tar xvzf - 2>&1; echo $?
@@ -26,6 +35,22 @@ tar: short read
"" ""
SKIP=
+testing "Two zeroed blocks is a ('truncated') empty tarball" '\
+dd if=/dev/zero bs=512 count=2 2>/dev/null | strace -o /tmp/zzz -tt -s99 tar xvf - 2>&1; echo $?
+' "\
+0
+" \
+"" ""
+SKIP=
+
+testing "Twenty zeroed blocks is an empty tarball" '\
+dd if=/dev/zero bs=512 count=20 2>/dev/null | tar xvf - 2>&1; echo $?
+' "\
+0
+" \
+"" ""
+SKIP=
+
optional FEATURE_TAR_CREATE FEATURE_LS_SORTFILES
testing "tar hardlinks and repeated files" '\
rm -rf input_* test.tar 2>/dev/null