summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_read.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2004-06-04 01:36:10 +0000
committerkientzle <kientzle@FreeBSD.org>2004-06-04 01:36:10 +0000
commit958eff641bf391ef0a040906ec30c871812f9f93 (patch)
tree27021727ed3c9f195a6f125796dbb814b7b41764 /lib/libarchive/archive_read.c
parent0d350a0b36af59510cb60373c1792b2e31936123 (diff)
downloadFreeBSD-src-958eff641bf391ef0a040906ec30c871812f9f93.zip
FreeBSD-src-958eff641bf391ef0a040906ec30c871812f9f93.tar.gz
Be more careful about the initial read (used for "tasting" the compression):
* Check for and return input errors * Treat empty file (zero-length read) as a fatal error
Diffstat (limited to 'lib/libarchive/archive_read.c')
-rw-r--r--lib/libarchive/archive_read.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/libarchive/archive_read.c b/lib/libarchive/archive_read.c
index 0ecd24b..57923ce 100644
--- a/lib/libarchive/archive_read.c
+++ b/lib/libarchive/archive_read.c
@@ -103,7 +103,7 @@ archive_read_open(struct archive *a, void *client_data,
archive_close_callback *closer)
{
const void *buffer;
- size_t bytes_read;
+ ssize_t bytes_read;
int high_bidder;
int e;
@@ -130,6 +130,17 @@ archive_read_open(struct archive *a, void *client_data,
/* Read first block now for format detection. */
bytes_read = (a->client_reader)(a, a->client_data, &buffer);
+ /* client_reader should have already set error information. */
+ if (bytes_read < 0)
+ return (ARCHIVE_FATAL);
+
+ /* An empty archive is a serious error. */
+ if (bytes_read == 0) {
+ archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Empty input file");
+ return (ARCHIVE_FATAL);
+ }
+
/* Select a decompression routine. */
high_bidder = choose_decompressor(a, buffer, bytes_read);
if (high_bidder < 0)
OpenPOWER on IntegriCloud