Skip to content

Commit 2920529

Browse files
committed
Add test for extracting ar archive without long filenames
1 parent 2f4e479 commit 2920529

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

tests/fixtures/README

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ Create archive.cpio
3333

3434
printf "/tmp/foo\0/123\0very-long-long-long-long-name\0very-long-long-long-long-name2\0very-long-name
3535
-with-newline\0a\nb\0dir/file\0" | cpio -ocv0 --owner=root:root > archive.cpio
36+
37+
38+
Create archive-no-ext_fnhdr.ar
39+
------------------------------
40+
41+
ar qP archive-no-ext_fnhdr.ar dir/file
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
!<arch>
2+
dir/file/ 1724142481 1000 1000 100644 14 `
3+
file-in-a-dir

tests/test_util_ar.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ def test_saveTo_abspath(self):
8181
# this is supposed to throw an error, extracting files with absolute paths might overwrite system files
8282
self.assertRaises(ArError, f.saveTo, self.tmpdir)
8383

84+
def test_no_exthdr(self):
85+
self.archive = os.path.join(FIXTURES_DIR, "archive-no-ext_fnhdr.ar")
86+
self.ar = Ar(self.archive)
87+
self.ar.read()
88+
self.test_saveTo_subdir()
89+
8490

8591
if __name__ == "__main__":
8692
unittest.main()

0 commit comments

Comments
 (0)