summaryrefslogtreecommitdiffstats
path: root/contrib/libarchive/tar/write.c
diff options
context:
space:
mode:
authormm <mm@FreeBSD.org>2017-01-02 01:43:11 +0000
committermm <mm@FreeBSD.org>2017-01-02 01:43:11 +0000
commitdf4798dc9511aa38aa412b763161b0927b955e11 (patch)
tree72d16a8900f63c42d2726f774bed694dfaa3a2ee /contrib/libarchive/tar/write.c
parentcd9bc4aa8c26fc251bae744bd07deff7f250e0b9 (diff)
downloadFreeBSD-src-df4798dc9511aa38aa412b763161b0927b955e11.zip
FreeBSD-src-df4798dc9511aa38aa412b763161b0927b955e11.tar.gz
MFC r309300,r309363,r309405,r309523,r309590,r310185,r310623:
Sync libarchive with vendor. Fixed vendor issues (relevant to FreeBSD) #825, #832: Add sanity check of tar "uid, "gid" and "mtime" fields #830, #831, #833, #846: Spelling fixes #850: Fix issues with reading certain jar files Fixed issues found by Google OSS-Fuzz: OSS-Fuzz #15: Fix heap-buffer-overflow in archive_le16dec() OSS-Fuzz #16: Fix possible hang in uudecode_filter_read() OSS-Fuzz #139, #145, #152: Fix heap-buffer-overflow in uudecode_bidder_bid() OSS-Fuzz #220: Reject an 'ar' filename table larger than 1GB or a filename larger than 1MB OSS-Fuzz #227, #230, #239: Fix possible memory leak in archive_read_free() OSS-Fuzz #237: Fix heap buffer overflow when reading invalid ar archives OSS-Fuzz #286: Bugfix in archive_strncat_l() More information: https://github.com/libarchive/libarchive/issues/[libarchive_issue_number] https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=[oss_fuzz_issue_number]
Diffstat (limited to 'contrib/libarchive/tar/write.c')
-rw-r--r--contrib/libarchive/tar/write.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/contrib/libarchive/tar/write.c b/contrib/libarchive/tar/write.c
index 18193de..4265d14 100644
--- a/contrib/libarchive/tar/write.c
+++ b/contrib/libarchive/tar/write.c
@@ -145,18 +145,17 @@ set_writer_options(struct bsdtar *bsdtar, struct archive *a)
writer_options = getenv(ENV_WRITER_OPTIONS);
if (writer_options != NULL) {
+ size_t module_len = sizeof(IGNORE_WRONG_MODULE_NAME) - 1;
+ size_t opt_len = strlen(writer_options) + 1;
char *p;
/* Set default write options. */
- p = malloc(sizeof(IGNORE_WRONG_MODULE_NAME)
- + strlen(writer_options) + 1);
- if (p == NULL)
+ if ((p = malloc(module_len + opt_len)) == NULL)
lafe_errc(1, errno, "Out of memory");
/* Prepend magic code to ignore options for
* a format or filters which are not added to
* the archive write object. */
- strncpy(p, IGNORE_WRONG_MODULE_NAME,
- sizeof(IGNORE_WRONG_MODULE_NAME) -1);
- strcpy(p + sizeof(IGNORE_WRONG_MODULE_NAME) -1, writer_options);
+ memcpy(p, IGNORE_WRONG_MODULE_NAME, module_len);
+ memcpy(p, writer_options, opt_len);
r = archive_write_set_options(a, p);
free(p);
if (r < ARCHIVE_WARN)
@@ -178,18 +177,18 @@ set_reader_options(struct bsdtar *bsdtar, struct archive *a)
reader_options = getenv(ENV_READER_OPTIONS);
if (reader_options != NULL) {
+ size_t module_len = sizeof(IGNORE_WRONG_MODULE_NAME) - 1;
+ size_t opt_len = strlen(reader_options) + 1;
char *p;
/* Set default write options. */
- p = malloc(sizeof(IGNORE_WRONG_MODULE_NAME)
- + strlen(reader_options) + 1);
+ if ((p = malloc(module_len + opt_len)) == NULL)
if (p == NULL)
lafe_errc(1, errno, "Out of memory");
/* Prepend magic code to ignore options for
* a format or filters which are not added to
* the archive write object. */
- strncpy(p, IGNORE_WRONG_MODULE_NAME,
- sizeof(IGNORE_WRONG_MODULE_NAME) -1);
- strcpy(p + sizeof(IGNORE_WRONG_MODULE_NAME) -1, reader_options);
+ memcpy(p, IGNORE_WRONG_MODULE_NAME, module_len);
+ memcpy(p, reader_options, opt_len);
r = archive_read_set_options(a, p);
free(p);
if (r < ARCHIVE_WARN)
@@ -527,7 +526,7 @@ write_archive(struct archive *a, struct bsdtar *bsdtar)
struct archive *disk = bsdtar->diskreader;
/*
- * This tricky code here is to correctly read the cotents
+ * This tricky code here is to correctly read the contents
* of the entry because the disk reader bsdtar->diskreader
* is pointing at does not have any information about the
* entry by this time and using archive_read_data_block()
OpenPOWER on IntegriCloud