]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix Issue 3: http://code.google.com/p/libarchive/issues/detail?id=3
authorTim Kientzle <kientzle@gmail.com>
Fri, 9 Jan 2009 06:49:07 +0000 (01:49 -0500)
committerTim Kientzle <kientzle@gmail.com>
Fri, 9 Jan 2009 06:49:07 +0000 (01:49 -0500)
This occurs with Zip archives that have entries that are
compressed with deflate even though they are zero bytes
long.  Libarchive's zip handler returns a zero-byte block
from the decompression before returning end-of-entry.
Writing that zero-byte block back to the filesystem
triggered some code intended to catch misuse of the API.

The fix suppresses the warning in the case of a zero-byte
write request.

This is all very silly: compressing a zero-byte file is
a silly thing to do, libarchive's zip format handler is
returning a silly sequence of responses, and the warning
is silly.  Oh, well.  At least I fixed the warning. ;-)

SVN-Revision: 407

libarchive/archive_write_disk.c

index 5aa50c19105c5ad8e2f1845ed2a1a52954f1c4d8..c1ddf77e734400d771fab11246ab25c436a53706 100644 (file)
@@ -519,6 +519,9 @@ write_data_block(struct archive_write_disk *a,
        ssize_t bytes_written = 0;
        ssize_t block_size = 0, bytes_to_write;
 
+       if (size == 0)
+               return (ARCHIVE_OK);
+
        if (a->filesize == 0 || a->fd < 0) {
                archive_set_error(&a->archive, 0,
                    "Attempt to write to an empty file");