From: Brian Harring Date: Thu, 23 Sep 2010 13:08:03 +0000 (-0400) Subject: add a format level data skip to cpio X-Git-Tag: v3.0.0a~883 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa4ffb037a9ef4477dcdda24375bd6adc7a32e51;p=thirdparty%2Flibarchive.git add a format level data skip to cpio SVN-Revision: 2694 --- diff --git a/libarchive/archive_read_support_format_cpio.c b/libarchive/archive_read_support_format_cpio.c index 8c6823f96..0dc82efae 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