aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2015-05-14 21:33:33 +0000
committerXin LI <delphij@FreeBSD.org>2015-05-14 21:33:33 +0000
commitc792c52ca146005fcffb6382b170556d99fa00ca (patch)
treea58e7673f1156f425839116c32dfe167cb4a368c
parent48ff71b692467e4a7e2173f1f1670ebc77116fad (diff)
downloadsrc-c792c52ca146005fcffb6382b170556d99fa00ca.tar.gz
src-c792c52ca146005fcffb6382b170556d99fa00ca.zip
Apply upstream changeset 3865cf2:
Issue 394: Segfault when reading malformed old-style cpio archives Root cause here was an implicit cast that resulted in reading very large file sizes as negative numbers.
Notes
Notes: svn path=/vendor/libarchive/dist/; revision=282927
-rw-r--r--libarchive/archive_read_support_format_cpio.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libarchive/archive_read_support_format_cpio.c b/libarchive/archive_read_support_format_cpio.c
index 819f4a4f531e..4a0452ddf7ca 100644
--- a/libarchive/archive_read_support_format_cpio.c
+++ b/libarchive/archive_read_support_format_cpio.c
@@ -198,7 +198,7 @@ static int archive_read_format_cpio_read_data(struct archive_read *,
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 int64_t be4(const unsigned char *);
static int find_odc_header(struct archive_read *);
static int find_newc_header(struct archive_read *);
static int header_bin_be(struct archive_read *, struct cpio *,
@@ -213,7 +213,7 @@ static int header_afiol(struct archive_read *, struct cpio *,
struct archive_entry *, size_t *, size_t *);
static int is_octal(const char *, size_t);
static int is_hex(const char *, size_t);
-static int le4(const unsigned char *);
+static int64_t le4(const unsigned char *);
static int record_hardlink(struct archive_read *a,
struct cpio *cpio, struct archive_entry *entry);
@@ -944,17 +944,17 @@ archive_read_format_cpio_cleanup(struct archive_read *a)
return (ARCHIVE_OK);
}
-static int
+static int64_t
le4(const unsigned char *p)
{
- return ((p[0]<<16) + (p[1]<<24) + (p[2]<<0) + (p[3]<<8));
+ return ((p[0] << 16) + (((int64_t)p[1]) << 24) + (p[2] << 0) + (p[3] << 8));
}
-static int
+static int64_t
be4(const unsigned char *p)
{
- return ((p[0]<<24) + (p[1]<<16) + (p[2]<<8) + (p[3]));
+ return ((((int64_t)p[0]) << 24) + (p[1] << 16) + (p[2] << 8) + (p[3]));
}
/*