aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Makemodule.am7
-rw-r--r--tests/tar/CREDITS3
-rw-r--r--tests/tar/file-size/12-digit.tarbin0 -> 2048 bytes
-rw-r--r--tests/tar/file-size/12-digit.tar.gz.gzbin99861 -> 0 bytes
-rw-r--r--tests/tar/file-size/ZIPBOMB-WARNING6
-rw-r--r--tests/tar/file-size/gnu.tarbin0 -> 2048 bytes
-rw-r--r--tests/tar/file-size/gnu.tar.gz.gzbin99827 -> 0 bytes
-rw-r--r--tests/tar/file-size/pax.tarbin0 -> 2048 bytes
-rw-r--r--tests/tar/file-size/pax.tar.gz.gzbin100215 -> 0 bytes
-rw-r--r--tests/tar_big_size.c79
10 files changed, 88 insertions, 7 deletions
diff --git a/tests/Makemodule.am b/tests/Makemodule.am
index 8bf818e..44c6eda 100644
--- a/tests/Makemodule.am
+++ b/tests/Makemodule.am
@@ -38,6 +38,10 @@ test_tar_formats_SOURCES = tests/tar_formats.c
test_tar_formats_LDADD = libtar.a libutil.a
test_tar_formats_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
+test_tar_big_size_SOURCES = tests/tar_big_size.c
+test_tar_big_size_LDADD = libtar.a libutil.a
+test_tar_big_size_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
+
test_tar_long_paths_SOURCES = tests/tar_long_paths.c
test_tar_long_paths_LDADD = libtar.a libutil.a
test_tar_long_paths_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
@@ -55,10 +59,11 @@ check_PROGRAMS += test_mknode_reg test_mknode_dir test_gen_inode_table
check_PROGRAMS += test_add_by_path test_get_path test_fstree_sort
check_PROGRAMS += test_fstree_from_file test_fstree_init test_fstree_xattr
check_PROGRAMS += test_tar_formats test_tar_long_paths test_tar_mtime
-check_PROGRAMS += test_tar_large_uid
+check_PROGRAMS += test_tar_large_uid test_tar_big_size
TESTS += test_canonicalize_name test_mknode_simple test_mknode_slink
TESTS += test_mknode_reg test_mknode_dir test_gen_inode_table
TESTS += test_add_by_path test_get_path test_fstree_sort test_fstree_from_file
TESTS += test_fstree_init test_fstree_xattr test_tar_formats
TESTS += test_tar_long_paths test_tar_mtime test_tar_large_uid
+TESTS += test_tar_big_size
diff --git a/tests/tar/CREDITS b/tests/tar/CREDITS
index 32014fc..e4b19b4 100644
--- a/tests/tar/CREDITS
+++ b/tests/tar/CREDITS
@@ -20,3 +20,6 @@ for those features:
- longe user + group names
- sun tar samples
- star samples
+
+In addition to that, the files in "file-size" are truncated, since we are only
+interested in parsing the header.
diff --git a/tests/tar/file-size/12-digit.tar b/tests/tar/file-size/12-digit.tar
new file mode 100644
index 0000000..a6b3553
--- /dev/null
+++ b/tests/tar/file-size/12-digit.tar
Binary files differ
diff --git a/tests/tar/file-size/12-digit.tar.gz.gz b/tests/tar/file-size/12-digit.tar.gz.gz
deleted file mode 100644
index aaa69e3..0000000
--- a/tests/tar/file-size/12-digit.tar.gz.gz
+++ /dev/null
Binary files differ
diff --git a/tests/tar/file-size/ZIPBOMB-WARNING b/tests/tar/file-size/ZIPBOMB-WARNING
deleted file mode 100644
index e530637..0000000
--- a/tests/tar/file-size/ZIPBOMB-WARNING
+++ /dev/null
@@ -1,6 +0,0 @@
-WARNING!
-
-The inner compressed tarballs in this directory are 8 GiB of size each.
-Be careful not to decompress them accidentally without preparing
-appropriate backing store (or having the decompressor smart about sparse
-files).
diff --git a/tests/tar/file-size/gnu.tar b/tests/tar/file-size/gnu.tar
new file mode 100644
index 0000000..aad726f
--- /dev/null
+++ b/tests/tar/file-size/gnu.tar
Binary files differ
diff --git a/tests/tar/file-size/gnu.tar.gz.gz b/tests/tar/file-size/gnu.tar.gz.gz
deleted file mode 100644
index 6ae4342..0000000
--- a/tests/tar/file-size/gnu.tar.gz.gz
+++ /dev/null
Binary files differ
diff --git a/tests/tar/file-size/pax.tar b/tests/tar/file-size/pax.tar
new file mode 100644
index 0000000..e391fee
--- /dev/null
+++ b/tests/tar/file-size/pax.tar
Binary files differ
diff --git a/tests/tar/file-size/pax.tar.gz.gz b/tests/tar/file-size/pax.tar.gz.gz
deleted file mode 100644
index 7c887d6..0000000
--- a/tests/tar/file-size/pax.tar.gz.gz
+++ /dev/null
Binary files differ
diff --git a/tests/tar_big_size.c b/tests/tar_big_size.c
new file mode 100644
index 0000000..3b5b557
--- /dev/null
+++ b/tests/tar_big_size.c
@@ -0,0 +1,79 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+#include "util.h"
+#include "tar.h"
+
+#include <unistd.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+#define STR(x) #x
+#define STRVALUE(x) STR(x)
+
+#define TEST_PATH STRVALUE(TESTPATH)
+
+static int open_read(const char *path)
+{
+ int fd = open(path, O_RDONLY);
+
+ if (fd < 0) {
+ perror(path);
+ exit(EXIT_FAILURE);
+ }
+
+ return fd;
+}
+
+int main(void)
+{
+ tar_header_decoded_t hdr;
+ int fd;
+
+ assert(chdir(TEST_PATH) == 0);
+
+ fd = open_read("file-size/pax.tar");
+ assert(read_header(fd, &hdr) == 0);
+ assert(hdr.sb.st_mode == (S_IFREG | 0644));
+ assert(hdr.sb.st_uid == 01750);
+ assert(hdr.sb.st_gid == 01750);
+ assert(hdr.sb.st_size == 8589934592);
+ assert(hdr.sb.st_mtime == 1542959190);
+ assert(hdr.sb.st_atime == 1542959522);
+ assert(hdr.sb.st_ctime == 1542959190);
+ assert(strcmp(hdr.name, "big-file.bin") == 0);
+ assert(!hdr.unknown_record);
+ clear_header(&hdr);
+ close(fd);
+
+ fd = open_read("file-size/gnu.tar");
+ assert(read_header(fd, &hdr) == 0);
+ assert(hdr.sb.st_mode == (S_IFREG | 0644));
+ assert(hdr.sb.st_uid == 01750);
+ assert(hdr.sb.st_gid == 01750);
+ assert(hdr.sb.st_size == 8589934592);
+ assert(hdr.sb.st_mtime == 013375730126);
+ assert(hdr.sb.st_atime == 013375730126);
+ assert(hdr.sb.st_ctime == 013375730126);
+ assert(strcmp(hdr.name, "big-file.bin") == 0);
+ assert(!hdr.unknown_record);
+ clear_header(&hdr);
+ close(fd);
+
+ fd = open_read("file-size/12-digit.tar");
+ assert(read_header(fd, &hdr) == 0);
+ assert(hdr.sb.st_mode == (S_IFREG | 0644));
+ assert(hdr.sb.st_uid == 01750);
+ assert(hdr.sb.st_gid == 01750);
+ assert(hdr.sb.st_size == 8589934592);
+ assert(hdr.sb.st_mtime == 013375730126);
+ assert(hdr.sb.st_atime == 013375730126);
+ assert(hdr.sb.st_ctime == 013375730126);
+ assert(strcmp(hdr.name, "big-file.bin") == 0);
+ assert(!hdr.unknown_record);
+ clear_header(&hdr);
+ close(fd);
+
+ return EXIT_SUCCESS;
+}