From f7ebdd04ab75324c1fbbfc7f0b1c459f0d561524 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Tue, 20 Aug 2024 10:38:54 +0200 Subject: [PATCH] Add test for extracting ar archive without long filenames --- tests/fixtures/README | 6 ++++++ tests/fixtures/archive-no-ext_fnhdr.ar | 3 +++ tests/test_util_ar.py | 6 ++++++ 3 files changed, 15 insertions(+) create mode 100644 tests/fixtures/archive-no-ext_fnhdr.ar diff --git a/tests/fixtures/README b/tests/fixtures/README index 2b7fa007f..2801ea7ef 100644 --- a/tests/fixtures/README +++ b/tests/fixtures/README @@ -33,3 +33,9 @@ Create archive.cpio printf "/tmp/foo\0/123\0very-long-long-long-long-name\0very-long-long-long-long-name2\0very-long-name -with-newline\0a\nb\0dir/file\0" | cpio -ocv0 --owner=root:root > archive.cpio + + +Create archive-no-ext_fnhdr.ar +------------------------------ + +ar qP archive-no-ext_fnhdr.ar dir/file diff --git a/tests/fixtures/archive-no-ext_fnhdr.ar b/tests/fixtures/archive-no-ext_fnhdr.ar new file mode 100644 index 000000000..1da64b1bc --- /dev/null +++ b/tests/fixtures/archive-no-ext_fnhdr.ar @@ -0,0 +1,3 @@ +! +dir/file/ 1724142481 1000 1000 100644 14 ` +file-in-a-dir diff --git a/tests/test_util_ar.py b/tests/test_util_ar.py index 227fd4737..099e7b4d1 100644 --- a/tests/test_util_ar.py +++ b/tests/test_util_ar.py @@ -81,6 +81,12 @@ def test_saveTo_abspath(self): # this is supposed to throw an error, extracting files with absolute paths might overwrite system files self.assertRaises(ArError, f.saveTo, self.tmpdir) + def test_no_exthdr(self): + self.archive = os.path.join(FIXTURES_DIR, "archive-no-ext_fnhdr.ar") + self.ar = Ar(self.archive) + self.ar.read() + self.test_saveTo_subdir() + if __name__ == "__main__": unittest.main()