]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Issue 185: Include the contributed Zip in the regression test,
authorTim Kientzle <kientzle@gmail.com>
Tue, 20 Sep 2011 05:21:22 +0000 (01:21 -0400)
committerTim Kientzle <kientzle@gmail.com>
Tue, 20 Sep 2011 05:21:22 +0000 (01:21 -0400)
include this and another recently added test file to the distribution
described by Makefile.am.

SVN-Revision: 3724

Makefile.am
libarchive/test/test_compat_zip.c
libarchive/test/test_compat_zip_3.zip.uu [new file with mode: 0644]

index 0a06c3ec519e63ccf7432b9703d7af10ed1f0c05..2117c58a5e1f52321b5c844d4fc9703761ba69eb 100644 (file)
@@ -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
index 8a3306af19ee92d39ddc29b978455dd9f35ee1b6..f036a7049354b6978b3987abe405a4add5d68339 100644 (file)
@@ -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, "<?xml versio", 12);
+       free(p);
+
+       assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+}
+
 
 DEFINE_TEST(test_compat_zip)
 {
        test_compat_zip_1();
        test_compat_zip_2();
+       test_compat_zip_3();
 }
 
 
diff --git a/libarchive/test/test_compat_zip_3.zip.uu b/libarchive/test/test_compat_zip_3.zip.uu
new file mode 100644 (file)
index 0000000..8e36139
--- /dev/null
@@ -0,0 +1,18 @@
+begin 644 test_compat_zip_3.zip
+M4$L#!`H``````-=0SCX````````````````-````<V]A<'5I+30N,"XP+U!+
+M`P04``@`"`#(4,X^C.NJ/7X!```&!```(````'-O87!U:2TT+C`N,"]S;V%P
+M=6DM<V5T=&EN9W,N>&ULI9/12\,P$,;?!?^'D0??DE1%D+EU0U`<*`RWH6\E
+MIK<MVB8UN:[;?^]UG6.H,*=0:.G=]\O7[ZZ=WC+/6@OPP3C;9:<B8BVPVJ7&
+MSKIL,K[EEZP7'Q]UM+/MX%11&AX`D<JA15(;VKH6SA&+MI2P,)7R(+3+9=,M
+MJ3PU,Q8WA$;:,FF7/84T&VU0?:WT''A%KP*+T9?0D3O]>\2%IZ<5+[RQR#V$
+MPMD`G-S]"G5'UK<H8W56II!X>"\A8&)L@B:'!-4;V/_@&E-_X$T&6YHJT25!
+M+6H,@E\H^L#HD*!@N;:3<EP50$&?9'A5"\"B7QTVSD#SRE5_TUA5E:C.A?,S
+M>19%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<D.O7LE4YN)DHI/O9KE5)%?(Y<__,CQ!U!+!PB,ZZH]
+M?@$```8$``!02P$"%`,*``````#74,X^````````````````#0``````````
+M`!``[4$`````<V]A<'5I+30N,"XP+U!+`0(4`Q0`"``(`,A0SCZ,ZZH]?@$`
+M``8$```@``````````````"D@2L```!S;V%P=6DM-"XP+C`O<V]A<'5I+7-E
+@='1I;F=S+GAM;%!+!08``````@`"`(D```#W`0``````
+`
+end