From: Tim Kientzle Date: Sun, 19 Oct 2008 22:01:45 +0000 (-0400) Subject: Don't read ahead more than necessary when scanning cpio headers. X-Git-Tag: v2.6.0~68 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8fe43667624c3c9b63ee2a9368cd859518ac63c2;p=thirdparty%2Flibarchive.git Don't read ahead more than necessary when scanning cpio headers. SVN-Revision: 225 --- 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));