summaryrefslogtreecommitdiff
path: root/libarchive/archive_read_support_format_cpio.c
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gmail.com>2010-09-23 09:08:03 -0400
committerBrian Harring <ferringb@gmail.com>2010-09-23 09:08:03 -0400
commitaa4ffb037a9ef4477dcdda24375bd6adc7a32e51 (patch)
tree43ebfc930d7979ff75e758ec5896237ec9e6b3b5 /libarchive/archive_read_support_format_cpio.c
parent4d19a06c51f3d91f859eda298e2babdf94487971 (diff)
downloadlibarchive-aa4ffb037a9ef4477dcdda24375bd6adc7a32e51.tar.gz
add a format level data skip to cpio
SVN-Revision: 2694
Diffstat (limited to 'libarchive/archive_read_support_format_cpio.c')
-rw-r--r--libarchive/archive_read_support_format_cpio.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/libarchive/archive_read_support_format_cpio.c b/libarchive/archive_read_support_format_cpio.c
index 8c6823f9..0dc82efa 100644
--- a/libarchive/archive_read_support_format_cpio.c
+++ b/libarchive/archive_read_support_format_cpio.c
@@ -147,6 +147,7 @@ static int archive_read_format_cpio_read_data(struct archive_read *,
const void **, size_t *, int64_t *);
static int archive_read_format_cpio_read_header(struct archive_read *,
struct archive_entry *);
+static int archive_read_format_cpio_skip(struct archive_read *);
static int be4(const unsigned char *);
static int find_odc_header(struct archive_read *);
static int find_newc_header(struct archive_read *);
@@ -190,7 +191,7 @@ archive_read_support_format_cpio(struct archive *_a)
NULL,
archive_read_format_cpio_read_header,
archive_read_format_cpio_read_data,
- NULL,
+ archive_read_format_cpio_skip,
archive_read_format_cpio_cleanup);
if (r != ARCHIVE_OK)
@@ -358,6 +359,22 @@ archive_read_format_cpio_read_data(struct archive_read *a,
}
}
+static int
+archive_read_format_cpio_skip(struct archive_read *a)
+{
+ struct cpio *cpio = (struct cpio *)(a->format->data);
+ int64_t to_skip = cpio->entry_bytes_remaining + cpio->entry_padding +
+ cpio->entry_bytes_unconsumed;
+
+ if (to_skip != __archive_read_consume(a, to_skip)) {
+ return (ARCHIVE_FATAL);
+ }
+ cpio->entry_bytes_remaining = 0;
+ cpio->entry_padding = 0;
+ cpio->entry_bytes_unconsumed = 0;
+ return (ARCHIVE_OK);
+}
+
/*
* Skip forward to the next cpio newc header by searching for the
* 07070[12] string. This should be generalized and merged with