diff options
author | kientzle <kientzle@FreeBSD.org> | 2010-11-07 03:40:37 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2010-11-07 03:40:37 +0000 |
commit | 709ff019d467067d0736588aa9e855a3db12abaa (patch) | |
tree | 0e5ed8aa7a61822ccf502fc2862de80776098f05 /lib/libarchive/test | |
parent | 9270446f7c7b3ce278eaeff10b801af559a65b09 (diff) | |
download | FreeBSD-src-709ff019d467067d0736588aa9e855a3db12abaa.zip FreeBSD-src-709ff019d467067d0736588aa9e855a3db12abaa.tar.gz |
If the Zip reader doesn't see a PK signature block
because there's inter-entry garbage, just scan forward
to find the next one. This allows us to handle a lot
of Zip archives that have been modified in-place.
Thanks to: Gleb Kurtsou for sending me a sample archive
Diffstat (limited to 'lib/libarchive/test')
-rw-r--r-- | lib/libarchive/test/test_compat_zip.c | 33 | ||||
-rw-r--r-- | lib/libarchive/test/test_compat_zip_2.zip.uu | 10 |
2 files changed, 43 insertions, 0 deletions
diff --git a/lib/libarchive/test/test_compat_zip.c b/lib/libarchive/test/test_compat_zip.c index fefc6fe..adb377c 100644 --- a/lib/libarchive/test/test_compat_zip.c +++ b/lib/libarchive/test/test_compat_zip.c @@ -71,10 +71,43 @@ finish: #endif } +/* + * Verify that we skip junk between entries. The compat_zip_2.zip file + * has several bytes of junk between 'file1' and 'file2'. Such + * junk is routinely introduced by some Zip writers when they manipulate + * existing zip archives. + */ +static void +test_compat_zip_2(void) +{ + char name[] = "test_compat_zip_2.zip"; + struct archive_entry *ae; + struct archive *a; + + assert((a = archive_read_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); + extract_reference_file(name); + assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240)); + + /* Read first entry. */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualString("file1", archive_entry_pathname(ae)); + + /* Read first entry. */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualString("file2", archive_entry_pathname(ae)); + + assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} + DEFINE_TEST(test_compat_zip) { test_compat_zip_1(); + test_compat_zip_2(); } diff --git a/lib/libarchive/test/test_compat_zip_2.zip.uu b/lib/libarchive/test/test_compat_zip_2.zip.uu new file mode 100644 index 0000000..c33e9d9 --- /dev/null +++ b/lib/libarchive/test/test_compat_zip_2.zip.uu @@ -0,0 +1,10 @@ +$FreeBSD$ + +begin 644 test_compat_zip_2.zip +M4$L#!`H``````'V59CT````````````````%````9FEL93$M2E5.2RU02P,$ +M"@``````@95F/<>D!,D&````!@````4```!F:6QE,F9I;&4R"E!+`0(>`PH` +M`````'V59CT````````````````%``````````````"D@0````!F:6QE,5!+ +M`0(>`PH``````(&59CW'I`3)!@````8````%``````````````"D@2D```!F +::6QE,E!+!08``````@`"`&8```!2```````` +` +end |