summaryrefslogtreecommitdiff
path: root/libarchive/archive_read_support_format_ar.c
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gmail.com>2010-09-23 07:40:18 -0400
committerBrian Harring <ferringb@gmail.com>2010-09-23 07:40:18 -0400
commit5792bdb9c259b61532ef25e42fd283c31f4277f8 (patch)
tree32a247ebad718016f0935db81461eb1d9720d587 /libarchive/archive_read_support_format_ar.c
parent584e506ddae97b0150bb10d02578046d0e6d464d (diff)
downloadlibarchive-5792bdb9c259b61532ef25e42fd283c31f4277f8.tar.gz
replace an adhoc consume/skip invocation with a proper skip/consume invocation (primarily relevant since the underlaying transforms/source may be able to shift to an lseek; unlikely, but it simplifies the code a bit). As for updating padding when the seek is less than what was requested, this is being done purely to keep existing behaviour- the ARCHIVE_FATAL return should make this a noop, but being safe.
SVN-Revision: 2691
Diffstat (limited to 'libarchive/archive_read_support_format_ar.c')
-rw-r--r--libarchive/archive_read_support_format_ar.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/libarchive/archive_read_support_format_ar.c b/libarchive/archive_read_support_format_ar.c
index ec79f5e9..ae6cb4b2 100644
--- a/libarchive/archive_read_support_format_ar.c
+++ b/libarchive/archive_read_support_format_ar.c
@@ -489,14 +489,16 @@ archive_read_format_ar_read_data(struct archive_read *a,
__archive_read_consume(a, (size_t)bytes_read);
return (ARCHIVE_OK);
} else {
- while (ar->entry_padding > 0) {
- *buff = __archive_read_ahead(a, 1, &bytes_read);
- if (bytes_read <= 0)
- return (ARCHIVE_FATAL);
- if (bytes_read > ar->entry_padding)
- bytes_read = (ssize_t)ar->entry_padding;
- __archive_read_consume(a, (size_t)bytes_read);
- ar->entry_padding -= bytes_read;
+ int64_t skipped = __archive_read_consume(a, ar->entry_padding);
+ if (skipped >= 0) {
+ ar->entry_padding -= skipped;
+ }
+ if (ar->entry_padding) {
+ if (skipped >= 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Truncated ar archive- failed consuming padding");
+ }
+ return (ARCHIVE_FATAL);
}
*buff = NULL;
*size = 0;