From: Tim Kientzle Date: Tue, 20 Sep 2011 05:21:22 +0000 (-0400) Subject: Issue 185: Include the contributed Zip in the regression test, X-Git-Tag: v3.0.0a~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67421348b346de8fe30ebdc24eb063b657e4de84;p=thirdparty%2Flibarchive.git Issue 185: Include the contributed Zip in the regression test, include this and another recently added test file to the distribution described by Makefile.am. SVN-Revision: 3724 --- diff --git a/Makefile.am b/Makefile.am index 0a06c3ec5..2117c58a5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -443,6 +443,7 @@ libarchive_test_EXTRA_DIST=\ libarchive/test/test_compat_xz_1.txz.uu \ libarchive/test/test_compat_zip_1.zip.uu \ libarchive/test/test_compat_zip_2.zip.uu \ + libarchive/test/test_compat_zip_3.zip.uu \ libarchive/test/test_fuzz_1.iso.Z.uu \ libarchive/test/test_fuzz.cab.uu \ libarchive/test/test_fuzz.lzh.uu \ @@ -518,6 +519,7 @@ libarchive_test_EXTRA_DIST=\ libarchive/test/test_read_format_zip_filename_utf8_jp.zip.uu \ libarchive/test/test_read_format_zip_filename_utf8_ru2.zip.uu \ libarchive/test/test_read_format_zip_filename_utf8_ru.zip.uu \ + libarchive/test/test_read_format_zip_length_at_end.zip.uu \ libarchive/test/test_read_format_zip_ux.zip.uu \ libarchive/test/CMakeLists.txt \ libarchive/test/README diff --git a/libarchive/test/test_compat_zip.c b/libarchive/test/test_compat_zip.c index 8a3306af1..f036a7049 100644 --- a/libarchive/test/test_compat_zip.c +++ b/libarchive/test/test_compat_zip.c @@ -99,11 +99,59 @@ test_compat_zip_2(void) assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } +/* + * Issue 185: Test a regression that got in between 2.6 and 2.7 that + * broke extraction of Zip entries with length-at-end. + */ +static void +test_compat_zip_3(void) +{ + const char *refname = "test_compat_zip_3.zip"; + struct archive_entry *ae; + struct archive *a; + char *p; + size_t s; + + extract_reference_file(refname); + assert((a = archive_read_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 10240)); + + /* First entry. */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualString("soapui-4.0.0/", archive_entry_pathname(ae)); + assertEqualInt(0, archive_entry_size(ae)); + assert(archive_entry_size_is_set(ae)); + assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); + + /* Second entry. */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualString("soapui-4.0.0/soapui-settings.xml", archive_entry_pathname(ae)); + assertEqualInt(AE_IFREG, archive_entry_filetype(ae)); + assertEqualInt(0, archive_entry_size(ae)); + assert(!archive_entry_size_is_set(ae)); + + /* Extract under a different name. */ + archive_entry_set_pathname(ae, "test_3.txt"); + assertEqualIntA(a, ARCHIVE_OK, archive_read_extract(a, ae, 0)); + /* Verify the first 12 bytes actually got written to disk correctly. */ + p = slurpfile(&s, "test_3.txt"); + assertEqualInt(s, 1030); + assertEqualMem(p, "&ULI9/12\,P$,;?!?^'D0??DE1%D+EU0U`<*`RWH6\E +MIK\2%IZ<5+[RQR#V$ +MPMD`G-S]"G5'UK"\A8&)L@B:'!-4;V/_@&E-_X$T&6YHJT25! +M+6H,@E\H^L#HD*!@N;:319%I_+YX7ZT;JA/D-LCXD/,6I731AB<\Q=CZWT\//Y<+1-JL*"1UCLD!?AD +M[@*R^"+:%]PW$#I4V2Z.Q?2M^S`4G?B,L8E0C.@V&?0KY]]"H32P6`A)UY@6 +M;GA]P[<%01/9@W\$3