]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
IFC
authorTim Kientzle <kientzle@gmail.com>
Tue, 21 Oct 2008 22:23:06 +0000 (18:23 -0400)
committerTim Kientzle <kientzle@gmail.com>
Tue, 21 Oct 2008 22:23:06 +0000 (18:23 -0400)
SVN-Revision: 232

libarchive/archive_read_support_format_zip.c
libarchive/archive_util.c
libarchive/config_windows.h
libarchive/test/test_read_format_zip.c
libarchive/test/test_read_format_zip.zip.uu

index 920060d433ee76d9a0bd1e1a49ed2b5dc2fefd3c..a7703502b214426953886622cdf440a5714fc861 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_zip.c,v 1.26 2008/06/30 16:19:26 des Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_zip.c,v 1.27 2008/10/21 05:08:35 kientzle Exp $");
 
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
@@ -439,7 +439,9 @@ zip_read_file_header(struct archive_read *a, struct archive_entry *entry,
        archive_entry_set_mtime(entry, zip->mtime, 0);
        archive_entry_set_ctime(entry, zip->ctime, 0);
        archive_entry_set_atime(entry, zip->atime, 0);
-       archive_entry_set_size(entry, zip->uncompressed_size);
+       /* Set the size only if it's meaningful. */
+       if (0 == (zip->flags & ZIP_LENGTH_AT_END))
+               archive_entry_set_size(entry, zip->uncompressed_size);
 
        zip->entry_bytes_remaining = zip->compressed_size;
        zip->entry_offset = 0;
@@ -568,12 +570,16 @@ archive_read_format_zip_read_data(struct archive_read *a,
                }
                break;
        }
+       if (r != ARCHIVE_OK)
+               return (r);
        /* Update checksum */
-       if (r == ARCHIVE_OK && *size) {
+       if (*size)
                zip->entry_crc32 =
                    crc32(zip->entry_crc32, *buff, *size);
-       }
-       return (r);
+       /* Return EOF immediately if this is a non-regular file. */
+       if (AE_IFREG != (zip->mode & AE_IFMT))
+               return (ARCHIVE_EOF);
+       return (ARCHIVE_OK);
 }
 
 /*
index 7fb46967715b2af5a1362c8cf526b8c571dca807..556508551ab2a34fc10b169965700782356b0cfd 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_util.c,v 1.18 2008/05/26 17:00:22 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_util.c,v 1.19 2008/10/21 12:10:30 des Exp $");
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -168,6 +168,7 @@ archive_set_error(struct archive *a, int error_number, const char *fmt, ...)
 
        va_start(ap, fmt);
        archive_string_vsprintf(&(a->error_string), fmt, ap);
+       va_end(ap);
        if (error_number > 0) {
                archive_strcat(&(a->error_string), ": ");
 #ifdef HAVE_STRERROR_R
@@ -184,7 +185,6 @@ archive_set_error(struct archive *a, int error_number, const char *fmt, ...)
                archive_strcat(&(a->error_string), errp);
        }
        a->error = a->error_string.s;
-       va_end(ap);
 }
 
 void
index 354b80aedc8b82d65a0f995541f345f93feacdc3..6a0560d9e567cb13497bf2af4b10ccad64a1c5f5 100644 (file)
 /* Define to 1 if you have the `geteuid' function. */
 /* #undef HAVE_GETEUID */
 
-/* Define to 1 if you have the `getopt_long' function. */
-/* #undef HAVE_GETOPT_LONG */
-
 /* Define to 1 if you have the `getxattr' function. */
 /* #undef HAVE_GETXATTR */
 
index edd26a403176894ccc0767b82fcd597747cdea23..a3da17e73b0b0cbd9ca45d35b96dd17de4a67ae9 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_zip.c,v 1.7 2008/09/01 05:38:33 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_zip.c,v 1.8 2008/10/21 05:08:35 kientzle Exp $");
+
+/*
+ * The reference file for this has been manually tweaked so that:
+ *   * file2 has length-at-end but file1 does not
+ *   * file2 has an invalid CRC
+ */
 
 DEFINE_TEST(test_read_format_zip)
 {
@@ -57,7 +63,8 @@ DEFINE_TEST(test_read_format_zip)
        assertA(0 == archive_read_next_header(a, &ae));
        assertEqualString("file2", archive_entry_pathname(ae));
        assertEqualInt(1179605932, archive_entry_mtime(ae));
-       assertEqualInt(18, archive_entry_size(ae));
+       failure("file2 has length-at-end, so we shouldn't see a valid size");
+       assertEqualInt(0, archive_entry_size_is_set(ae));
        failure("file2 has a bad CRC, so reading to end should fail");
        assertEqualInt(ARCHIVE_WARN, archive_read_data(a, buff, 19));
        assert(0 == memcmp(buff, "hello\nhello\nhello\n", 18));
index cf84ad3930022be71e68e8e3ceff3dad395a3cd0..b1f04c4fea00fcb4adefae4f461198bda2756821 100644 (file)
@@ -1,13 +1,14 @@
-$FreeBSD: src/lib/libarchive/test/test_read_format_zip.zip.uu,v 1.2 2008/06/26 11:50:11 des Exp $
+$FreeBSD: src/lib/libarchive/test/test_read_format_zip.zip.uu,v 1.3 2008/10/21 05:08:35 kientzle Exp $
 begin 644 test_read_format_zip.zip
-M4$L#!`H``````%EFLS8````````````````$`!4`9&ER+U54"0`#&55/1AE5
-M3T95>`0`Z`/H`U!+`P04````"`!O9K,V.C=F/0H````2````!0`5`&9I;&4Q
-M550)``-!54]&K%M/1E5X!`#H`^@#RTC-R<GGRD`B`5!+`P04````"`!::K,V
-M>%8T$@H````2````!0`5`&9I;&4R550)``.L6T]&K%M/1E5X!`#H`^@#RTC-
-MR<GGRD`B`5!+`0(7`PH``````%EFLS8````````````````$``T`````````
-M$`#M00````!D:7(O550%``,954]&57@``%!+`0(7`Q0````(`&]FLS8Z-V8]
-M"@```!(````%``T```````$```"D@3<```!F:6QE,554!0`#055/1E5X``!0
-M2P$"%P,4````"`!::K,V>%8T$@H````2````!0`-```````!````I(%Y````
-H9FEL93)55`4``ZQ;3T95>```4$L%!@`````#``,`OP```+L`````````
+M4$L#!`H`"````%EFLS8````````````````$`!4`9&ER+U54"0`#&55/1M19
+M_4A5>`0`Z`/H`U!+!P@```````````````!02P,$%`````@`;V:S-CHW9CT*
+M````$@````4`%0!F:6QE,554"0`#055/1L!9_4A5>`0`Z`/H`\M(S<G)Y\I`
+M(@%02P,$%``(``@`6FJS-@``````````$@````4`%0!F:6QE,E54"0`#K%M/
+M1L!9_4A5>`0`Z`/H`\M(S<G)Y\I`(@%02P<(.C=F$@H````2````4$L!`A<#
+M"@`(````66:S-@````````````````0`#0`````````0`.U!`````&1I<B]5
+M5`4``QE53T95>```4$L!`A<#%``(``@`;V:S-CHW9CT*````$@````4`#0``
+M`````0```.V!1P```&9I;&4Q550%``-!54]&57@``%!+`0(7`Q0`"``(`%IJ
+MLS8Z-V8]"@```!(````%``T```````$```#M@8D```!F:6QE,E54!0`#K%M/
+;1E5X``!02P4&``````,``P"_````VP``````
 `
 end