Correct the return values of the final zero-length block at EOF.

Return EOF immediately if an entry in a ZIP archive has no body.
In particular, the latter issue was causing bsdtar to emit spurious
warnings when extracting directory entries from ZIP archives.

MFC after: 3 days
This commit is contained in:
Tim Kientzle 2007-10-12 04:08:28 +00:00
parent 58d14dae6d
commit 04a832627b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=172559

View file

@ -335,6 +335,10 @@ zip_read_file_header(struct archive_read *a, struct archive_entry *entry,
zip->entry_bytes_remaining = zip->compressed_size;
zip->entry_offset = 0;
/* If there's no body, force read_data() to return EOF immediately. */
if (zip->entry_bytes_remaining < 1)
zip->end_of_entry = 1;
/* Set up a more descriptive format name. */
sprintf(zip->format_name, "ZIP %d.%d (%s)",
zip->version / 10, zip->version % 10,
@ -422,6 +426,9 @@ archive_read_format_zip_read_data(struct archive_read *a,
/* End-of-entry cleanup done. */
zip->end_of_entry_cleanup = 1;
}
*offset = zip->entry_uncompressed_bytes_read;
*size = 0;
*buff = NULL;
return (ARCHIVE_EOF);
}