]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
add a format level data skip to cpio
authorBrian Harring <ferringb@gmail.com>
Thu, 23 Sep 2010 13:08:03 +0000 (09:08 -0400)
committerBrian Harring <ferringb@gmail.com>
Thu, 23 Sep 2010 13:08:03 +0000 (09:08 -0400)
SVN-Revision: 2694

libarchive/archive_read_support_format_cpio.c

index 8c6823f969d601834d9c3160c91a2f9c1634bcb7..0dc82efae70fe8033b19a7f7a09d538fb30c6496 100644 (file)
@@ -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