From 8fe43667624c3c9b63ee2a9368cd859518ac63c2 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sun, 19 Oct 2008 18:01:45 -0400 Subject: [PATCH] Don't read ahead more than necessary when scanning cpio headers. SVN-Revision: 225 --- libarchive/archive_read_support_format_cpio.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libarchive/archive_read_support_format_cpio.c b/libarchive/archive_read_support_format_cpio.c index 2c50abc6b..3734b3863 100644 --- a/libarchive/archive_read_support_format_cpio.c +++ b/libarchive/archive_read_support_format_cpio.c @@ -339,7 +339,8 @@ find_newc_header(struct archive_read *a) size_t skip, bytes, skipped = 0; for (;;) { - bytes = (a->decompressor->read_ahead)(a, &h, 2048); + bytes = (a->decompressor->read_ahead)(a, &h, + sizeof(struct cpio_newc_header)); if (bytes < sizeof(struct cpio_newc_header)) return (ARCHIVE_FATAL); p = h; @@ -404,7 +405,8 @@ header_newc(struct archive_read *a, struct cpio *cpio, return (r); /* Read fixed-size portion of header. */ - bytes = (a->decompressor->read_ahead)(a, &h, sizeof(struct cpio_newc_header)); + bytes = (a->decompressor->read_ahead)(a, &h, + sizeof(struct cpio_newc_header)); if (bytes < sizeof(struct cpio_newc_header)) return (ARCHIVE_FATAL); (a->decompressor->consume)(a, sizeof(struct cpio_newc_header)); @@ -474,7 +476,8 @@ find_odc_header(struct archive_read *a) size_t skip, bytes, skipped = 0; for (;;) { - bytes = (a->decompressor->read_ahead)(a, &h, 512); + bytes = (a->decompressor->read_ahead)(a, &h, + sizeof(struct cpio_odc_header)); if (bytes < sizeof(struct cpio_odc_header)) return (ARCHIVE_FATAL); p = h; @@ -541,7 +544,8 @@ header_odc(struct archive_read *a, struct cpio *cpio, return (r); /* Read fixed-size portion of header. */ - bytes = (a->decompressor->read_ahead)(a, &h, sizeof(struct cpio_odc_header)); + bytes = (a->decompressor->read_ahead)(a, &h, + sizeof(struct cpio_odc_header)); if (bytes < sizeof(struct cpio_odc_header)) return (ARCHIVE_FATAL); (a->decompressor->consume)(a, sizeof(struct cpio_odc_header)); @@ -584,7 +588,8 @@ header_bin_le(struct archive_read *a, struct cpio *cpio, a->archive.archive_format_name = "cpio (little-endian binary)"; /* Read fixed-size portion of header. */ - bytes = (a->decompressor->read_ahead)(a, &h, sizeof(struct cpio_bin_header)); + bytes = (a->decompressor->read_ahead)(a, &h, + sizeof(struct cpio_bin_header)); if (bytes < sizeof(struct cpio_bin_header)) return (ARCHIVE_FATAL); (a->decompressor->consume)(a, sizeof(struct cpio_bin_header)); -- 2.47.3