diff options
author | kientzle <kientzle@FreeBSD.org> | 2009-09-08 05:02:41 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2009-09-08 05:02:41 +0000 |
commit | 081d756b8d796892f6067516bcae5d96fff34b57 (patch) | |
tree | aa659235a766562489c5e5df50433c586b4b04bf /lib/libarchive/archive_read.c | |
parent | aefa5719c9febd5d7d43ffb17e2f771ff9ccccea (diff) | |
download | FreeBSD-src-081d756b8d796892f6067516bcae5d96fff34b57.zip FreeBSD-src-081d756b8d796892f6067516bcae5d96fff34b57.tar.gz |
Fiz /usr/bin/unzip: A bug deep in libarchive's read-ahead logic
(incorrect handling of zero-length reads before the copy buffer is
allocated) is masked by the iso9660 taster. Tar and cpio both enable
that taster so were protected from the bug; unzip is susceptible.
This both fixes the bug and updates the test harness to exercise
this case.
Submitted by: Ed Schouten diagnosed the bug and drafted a patch
MFC after: 7 days
Diffstat (limited to 'lib/libarchive/archive_read.c')
-rw-r--r-- | lib/libarchive/archive_read.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libarchive/archive_read.c b/lib/libarchive/archive_read.c index 9274d66..fd4f888 100644 --- a/lib/libarchive/archive_read.c +++ b/lib/libarchive/archive_read.c @@ -928,9 +928,12 @@ __archive_read_filter_ahead(struct archive_read_filter *filter, for (;;) { /* - * If we can satisfy from the copy buffer, we're done. + * If we can satisfy from the copy buffer (and the + * copy buffer isn't empty), we're done. In particular, + * note that min == 0 is a perfectly well-defined + * request. */ - if (filter->avail >= min) { + if (filter->avail >= min && filter->avail > 0) { if (avail != NULL) *avail = filter->avail; return (filter->next); |