Skip to content

Commit

Permalink
Add test for extracting ar archive without long filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
dmach committed Aug 20, 2024
1 parent 0771980 commit f7ebdd0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/fixtures/README
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions tests/fixtures/archive-no-ext_fnhdr.ar
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
!<arch>
dir/file/ 1724142481 1000 1000 100644 14 `
file-in-a-dir
6 changes: 6 additions & 0 deletions tests/test_util_ar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit f7ebdd0

Please sign in to comment.