summaryrefslogtreecommitdiff
path: root/libarchive/archive_read_support_format_cpio.c
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@gmail.com>2008-10-19 18:01:45 -0400
committerTim Kientzle <kientzle@gmail.com>2008-10-19 18:01:45 -0400
commit8fe43667624c3c9b63ee2a9368cd859518ac63c2 (patch)
treec30add624a4aad5bd07d77ce327ebe79c413718e /libarchive/archive_read_support_format_cpio.c
parentff42af1a32f5c9473b559ce70fe283d0c94cf116 (diff)
downloadlibarchive-8fe43667624c3c9b63ee2a9368cd859518ac63c2.tar.gz
Don't read ahead more than necessary when scanning cpio headers.
SVN-Revision: 225
Diffstat (limited to 'libarchive/archive_read_support_format_cpio.c')
-rw-r--r--libarchive/archive_read_support_format_cpio.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libarchive/archive_read_support_format_cpio.c b/libarchive/archive_read_support_format_cpio.c
index 2c50abc6..3734b386 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));