summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2005-09-21 04:48:52 +0000
committerkientzle <kientzle@FreeBSD.org>2005-09-21 04:48:52 +0000
commit0fd9f664d7add62626dcbe97b41e09f01d3ddab9 (patch)
treecd93517afe37745d94ea10eb0b5d8758cc5d837b /lib
parentfc1e5e377c8e1e29a5131d2328685503cef2feb7 (diff)
downloadFreeBSD-src-0fd9f664d7add62626dcbe97b41e09f01d3ddab9.zip
FreeBSD-src-0fd9f664d7add62626dcbe97b41e09f01d3ddab9.tar.gz
In archive_read_open(), do not set the internal archive state to
"HEADER" unless the open is successful. Instead, leave the state as "NEW." In particular, if archive_read_open() fails, a subsequent call to archive_read_next_header() will now cause an explicit assertion failure instead of a silent segmentation fault. This may need a little more work to fully realize the intention: If archive_read_open() fails, you should be able to call it again on the same archive handle to open a different archive (or the same archive using a different mechanism).
Diffstat (limited to 'lib')
-rw-r--r--lib/libarchive/archive_read.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libarchive/archive_read.c b/lib/libarchive/archive_read.c
index 1d8f86d..5a1c114 100644
--- a/lib/libarchive/archive_read.c
+++ b/lib/libarchive/archive_read.c
@@ -126,8 +126,6 @@ archive_read_open(struct archive *a, void *client_data,
a->client_closer = closer;
a->client_data = client_data;
- a->state = ARCHIVE_STATE_HEADER;
-
/* Open data source. */
if (a->client_opener != NULL) {
e =(a->client_opener)(a, a->client_data);
@@ -156,6 +154,10 @@ archive_read_open(struct archive *a, void *client_data,
/* Initialize decompression routine with the first block of data. */
e = (a->decompressors[high_bidder].init)(a, buffer, bytes_read);
+
+ if (e == ARCHIVE_OK)
+ a->state = ARCHIVE_STATE_HEADER;
+
return (e);
}
OpenPOWER on IntegriCloud