summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2004-10-17 23:40:10 +0000
committerkientzle <kientzle@FreeBSD.org>2004-10-17 23:40:10 +0000
commit2f1227d293d3abebbf9fb61d07ab6ad5c410f952 (patch)
treed7b0f2635e0912571eca9728de72d1e909d89cbf /lib
parent094933a38d8a5200ad081d2b2ef450013e650f47 (diff)
downloadFreeBSD-src-2f1227d293d3abebbf9fb61d07ab6ad5c410f952.zip
FreeBSD-src-2f1227d293d3abebbf9fb61d07ab6ad5c410f952.tar.gz
Refine the error-checking and reporting in the
"compress" format decompression code. In particular, distinguish between EOF and fatal data errors.
Diffstat (limited to 'lib')
-rw-r--r--lib/libarchive/archive_read_support_compression_compress.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/libarchive/archive_read_support_compression_compress.c b/lib/libarchive/archive_read_support_compression_compress.c
index 93683eb..f6ec9f0 100644
--- a/lib/libarchive/archive_read_support_compression_compress.c
+++ b/lib/libarchive/archive_read_support_compression_compress.c
@@ -295,8 +295,10 @@ read_ahead(struct archive *a, const void **p, size_t min)
read_avail++;
} else {
ret = next_code(a, state);
- if (ret)
+ if (ret == ARCHIVE_EOF)
state->end_of_stream = ret;
+ else if (ret != ARCHIVE_OK)
+ return (ret);
}
}
}
@@ -346,7 +348,8 @@ finish(struct archive *a)
/*
* Process the next code and fill the stack with the expansion
- * of the code. Returns TRUE if we hit the end of the data.
+ * of the code. Returns ARCHIVE_FATAL if there is a fatal I/O or
+ * format error, ARCHIVE_EOF if we hit end of data, ARCHIVE_OK otherwise.
*/
static int
next_code(struct archive *a, struct private_data *state)
@@ -391,9 +394,11 @@ next_code(struct archive *a, struct private_data *state)
return (next_code(a, state));
}
- if (code > state->free_ent)
- /* XXX invalid code? This is fatal. XXX */
- return (1);
+ if (code > state->free_ent) {
+ /* An invalid code is a fatal error. */
+ archive_set_error(a, -1, "Invalid compressed data");
+ return (ARCHIVE_FATAL);
+ }
/* Special case for KwKwK string. */
if (code >= state->free_ent) {
@@ -426,7 +431,7 @@ next_code(struct archive *a, struct private_data *state)
/* Remember previous code. */
state->oldcode = newcode;
- return (0);
+ return (ARCHIVE_OK);
}
/*
OpenPOWER on IntegriCloud