aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2016-12-27 00:51:53 +0000
committerMartin Matuska <mm@FreeBSD.org>2016-12-27 00:51:53 +0000
commitcda329a1ca4579ea4cef22edbcc299737dd8cb76 (patch)
treeb7a646cd83cbffa9f0b2c8e55459db5f3175050d
parentfb179c62da3d1cc4313f6f8f8e53b2e319999dd3 (diff)
downloadsrc-cda329a1ca4579ea4cef22edbcc299737dd8cb76.tar.gz
src-cda329a1ca4579ea4cef22edbcc299737dd8cb76.zip
Update vendor/libarchive to git to 42a3408ac7df1e69bea9ea12b72e14f59f7400c0
Vendor bugfixes: PR 844: Coverity bug fixes in tests PR 846: Spelling fixes PR 850: Fix issues with reading certain jar files PR 826: OpenSSL 1.1 support PR 830, 831, 833: Spelling fixes 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()
Notes
Notes: svn path=/vendor/libarchive/dist/; revision=310622
-rw-r--r--Makefile.am2
-rw-r--r--cpio/test/test_owner_parse.c2
-rw-r--r--libarchive/archive_read.c2
-rw-r--r--libarchive/archive_read_disk_posix.c2
-rw-r--r--libarchive/archive_read_disk_windows.c2
-rw-r--r--libarchive/archive_read_support_filter_xz.c4
-rw-r--r--libarchive/archive_read_support_format_7zip.c17
-rw-r--r--libarchive/archive_read_support_format_cpio.c2
-rw-r--r--libarchive/archive_read_support_format_zip.c36
-rw-r--r--libarchive/archive_string.c18
-rw-r--r--libarchive/archive_write_set_format_iso9660.c18
-rw-r--r--libarchive/test/CMakeLists.txt1
-rw-r--r--libarchive/test/test_read_disk_directory_traversals.c10
-rw-r--r--libarchive/test/test_read_format_zip_jar.c59
-rw-r--r--libarchive/test/test_read_format_zip_jar.jar.uu6
-rw-r--r--libarchive/test/test_write_disk_appledouble.c4
-rw-r--r--libarchive/test/test_write_format_xar_empty.c2
-rw-r--r--libarchive/test/test_write_format_zip_empty.c2
-rw-r--r--libarchive/test/test_write_format_zip_empty_zip64.c2
-rw-r--r--tar/read.c11
-rw-r--r--tar/write.c21
21 files changed, 143 insertions, 80 deletions
diff --git a/Makefile.am b/Makefile.am
index 614f8641732a..6ed04959aff4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -483,6 +483,7 @@ libarchive_test_SOURCES= \
libarchive/test/test_read_format_zip_encryption_header.c \
libarchive/test/test_read_format_zip_filename.c \
libarchive/test/test_read_format_zip_high_compression.c \
+ libarchive/test/test_read_format_zip_jar.c \
libarchive/test/test_read_format_zip_mac_metadata.c \
libarchive/test/test_read_format_zip_malformed.c \
libarchive/test/test_read_format_zip_msdos.c \
@@ -801,6 +802,7 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_format_zip_filename_utf8_ru2.zip.uu \
libarchive/test/test_read_format_zip_high_compression.zip.uu \
libarchive/test/test_read_format_zip_length_at_end.zip.uu \
+ libarchive/test/test_read_format_zip_jar.jar.uu \
libarchive/test/test_read_format_zip_mac_metadata.zip.uu \
libarchive/test/test_read_format_zip_malformed1.zip.uu \
libarchive/test/test_read_format_zip_msdos.zip.uu \
diff --git a/cpio/test/test_owner_parse.c b/cpio/test/test_owner_parse.c
index a9f605398e36..bef02da7badf 100644
--- a/cpio/test/test_owner_parse.c
+++ b/cpio/test/test_owner_parse.c
@@ -38,7 +38,7 @@ static const int root_gids[] = { 0, 1 };
* its primary group membership depends on how the user set up
* their /etc/passwd. Likely values are 513 (None), 545 (Users),
* or 544 (Administrators). Just check for one of those...
- * TODO: Handle non-English localizations...e.g. French 'Administrateur'
+ * TODO: Handle non-English localizations... e.g. French 'Administrateur'
* Use CreateWellKnownSID() and LookupAccountName()?
*/
#define ROOT "Administrator"
diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c
index d490d7b41e82..d1fecebfd09f 100644
--- a/libarchive/archive_read.c
+++ b/libarchive/archive_read.c
@@ -764,7 +764,7 @@ archive_read_header_position(struct archive *_a)
* we cannot say whether there are encrypted entries, then
* ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
* In general, this function will return values below zero when the
- * reader is uncertain or totally uncapable of encryption support.
+ * reader is uncertain or totally incapable of encryption support.
* When this function returns 0 you can be sure that the reader
* supports encryption detection but no encrypted entries have
* been found yet.
diff --git a/libarchive/archive_read_disk_posix.c b/libarchive/archive_read_disk_posix.c
index 3cc5168e491b..bc7fad1d9d2e 100644
--- a/libarchive/archive_read_disk_posix.c
+++ b/libarchive/archive_read_disk_posix.c
@@ -1026,7 +1026,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
/* Save the times to be restored. This must be in before
* calling archive_read_disk_descend() or any chance of it,
- * especially, invokng a callback. */
+ * especially, invoking a callback. */
t->restore_time.mtime = archive_entry_mtime(entry);
t->restore_time.mtime_nsec = archive_entry_mtime_nsec(entry);
t->restore_time.atime = archive_entry_atime(entry);
diff --git a/libarchive/archive_read_disk_windows.c b/libarchive/archive_read_disk_windows.c
index 993a1dc40dc2..6791b2c13620 100644
--- a/libarchive/archive_read_disk_windows.c
+++ b/libarchive/archive_read_disk_windows.c
@@ -862,7 +862,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
/* Save the times to be restored. This must be in before
* calling archive_read_disk_descend() or any chance of it,
- * especially, invokng a callback. */
+ * especially, invoking a callback. */
t->restore_time.lastWriteTime = st->ftLastWriteTime;
t->restore_time.lastAccessTime = st->ftLastAccessTime;
t->restore_time.filetype = archive_entry_filetype(entry);
diff --git a/libarchive/archive_read_support_filter_xz.c b/libarchive/archive_read_support_filter_xz.c
index 023c349d81f0..11807cf6768b 100644
--- a/libarchive/archive_read_support_filter_xz.c
+++ b/libarchive/archive_read_support_filter_xz.c
@@ -293,7 +293,7 @@ lzma_bidder_bid(struct archive_read_filter_bidder *self,
/* Second through fifth bytes are dictionary size, stored in
* little-endian order. The minimum dictionary size is
* 1 << 12(4KiB) which the lzma of LZMA SDK uses with option
- * -d12 and the maxinam dictionary size is 1 << 27(128MiB)
+ * -d12 and the maximum dictionary size is 1 << 27(128MiB)
* which the one uses with option -d27.
* NOTE: A comment of LZMA SDK source code says this dictionary
* range is from 1 << 12 to 1 << 30. */
@@ -584,9 +584,7 @@ lzip_init(struct archive_read_filter *self)
return (ARCHIVE_FATAL);
}
ret = lzma_raw_decoder(&(state->stream), filters);
-#if LZMA_VERSION < 50010000
free(filters[0].options);
-#endif
if (ret != LZMA_OK) {
set_error(self, ret);
return (ARCHIVE_FATAL);
diff --git a/libarchive/archive_read_support_format_7zip.c b/libarchive/archive_read_support_format_7zip.c
index 268daa20106b..f8d52fb71797 100644
--- a/libarchive/archive_read_support_format_7zip.c
+++ b/libarchive/archive_read_support_format_7zip.c
@@ -263,22 +263,22 @@ struct _7zip {
/*
* Decompressor controllers.
*/
- /* Decording LZMA1 and LZMA2 data. */
+ /* Decoding LZMA1 and LZMA2 data. */
#ifdef HAVE_LZMA_H
lzma_stream lzstream;
int lzstream_valid;
#endif
- /* Decording bzip2 data. */
+ /* Decoding bzip2 data. */
#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR)
bz_stream bzstream;
int bzstream_valid;
#endif
- /* Decording deflate data. */
+ /* Decoding deflate data. */
#ifdef HAVE_ZLIB_H
z_stream stream;
int stream_valid;
#endif
- /* Decording PPMd data. */
+ /* Decoding PPMd data. */
int ppmd7_stat;
CPpmd7 ppmd7_context;
CPpmd7z_RangeDec range_dec;
@@ -1056,10 +1056,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
#endif
{
lzma_options_delta delta_opt;
- lzma_filter filters[LZMA_FILTERS_MAX];
-#if LZMA_VERSION < 50010000
- lzma_filter *ff;
-#endif
+ lzma_filter filters[LZMA_FILTERS_MAX], *ff;
int fi = 0;
if (zip->lzstream_valid) {
@@ -1144,9 +1141,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
else
filters[fi].id = LZMA_FILTER_LZMA1;
filters[fi].options = NULL;
-#if LZMA_VERSION < 50010000
ff = &filters[fi];
-#endif
r = lzma_properties_decode(&filters[fi], NULL,
coder1->properties, (size_t)coder1->propertiesSize);
if (r != LZMA_OK) {
@@ -1158,9 +1153,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
filters[fi].id = LZMA_VLI_UNKNOWN;
filters[fi].options = NULL;
r = lzma_raw_decoder(&(zip->lzstream), filters);
-#if LZMA_VERSION < 50010000
free(ff->options);
-#endif
if (r != LZMA_OK) {
set_error(a, r);
return (ARCHIVE_FAILED);
diff --git a/libarchive/archive_read_support_format_cpio.c b/libarchive/archive_read_support_format_cpio.c
index 7438babb60d1..89f9188cd104 100644
--- a/libarchive/archive_read_support_format_cpio.c
+++ b/libarchive/archive_read_support_format_cpio.c
@@ -326,7 +326,7 @@ archive_read_format_cpio_options(struct archive_read *a,
cpio = (struct cpio *)(a->format->data);
if (strcmp(key, "compat-2x") == 0) {
- /* Handle filnames as libarchive 2.x */
+ /* Handle filenames as libarchive 2.x */
cpio->init_default_conversion = (val != NULL)?1:0;
return (ARCHIVE_OK);
} else if (strcmp(key, "hdrcharset") == 0) {
diff --git a/libarchive/archive_read_support_format_zip.c b/libarchive/archive_read_support_format_zip.c
index 9796fca161a6..d19e7914e11c 100644
--- a/libarchive/archive_read_support_format_zip.c
+++ b/libarchive/archive_read_support_format_zip.c
@@ -864,29 +864,33 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
zip_entry->mode |= AE_IFREG;
}
- if ((zip_entry->mode & AE_IFMT) == 0) {
- /* Especially in streaming mode, we can end up
- here without having seen proper mode information.
- Guess from the filename. */
+ /* If the mode is totally empty, set some sane default. */
+ if (zip_entry->mode == 0) {
+ zip_entry->mode |= 0664;
+ }
+
+ /* Make sure that entries with a trailing '/' are marked as directories
+ * even if the External File Attributes contains bogus values. If this
+ * is not a directory and there is no type, assume regularfile. */
+ if ((zip_entry->mode & AE_IFMT) != AE_IFDIR) {
+ int has_slash;
+
wp = archive_entry_pathname_w(entry);
if (wp != NULL) {
len = wcslen(wp);
- if (len > 0 && wp[len - 1] == L'/')
- zip_entry->mode |= AE_IFDIR;
- else
- zip_entry->mode |= AE_IFREG;
+ has_slash = len > 0 && wp[len - 1] == L'/';
} else {
cp = archive_entry_pathname(entry);
len = (cp != NULL)?strlen(cp):0;
- if (len > 0 && cp[len - 1] == '/')
- zip_entry->mode |= AE_IFDIR;
- else
- zip_entry->mode |= AE_IFREG;
+ has_slash = len > 0 && cp[len - 1] == '/';
}
- if (zip_entry->mode == AE_IFDIR) {
- zip_entry->mode |= 0775;
- } else if (zip_entry->mode == AE_IFREG) {
- zip_entry->mode |= 0664;
+ /* Correct file type as needed. */
+ if (has_slash) {
+ zip_entry->mode &= ~AE_IFMT;
+ zip_entry->mode |= AE_IFDIR;
+ zip_entry->mode |= 0111;
+ } else if ((zip_entry->mode & AE_IFMT) == 0) {
+ zip_entry->mode |= AE_IFREG;
}
}
diff --git a/libarchive/archive_string.c b/libarchive/archive_string.c
index aa57f01549f5..bbb1e4585180 100644
--- a/libarchive/archive_string.c
+++ b/libarchive/archive_string.c
@@ -1827,7 +1827,7 @@ archive_string_conversion_set_opt(struct archive_string_conv *sc, int opt)
* A filename in UTF-8 was made with libarchive 2.x in a wrong
* assumption that wchar_t was Unicode.
* This option enables simulating the assumption in order to read
- * that filname correctly.
+ * that filename correctly.
*/
case SCONV_SET_OPT_UTF8_LIBARCHIVE2X:
#if (defined(_WIN32) && !defined(__CYGWIN__)) \
@@ -1939,12 +1939,19 @@ archive_strncat_l(struct archive_string *as, const void *_p, size_t n,
struct archive_string_conv *sc)
{
const void *s;
- size_t length;
+ size_t length = 0;
int i, r = 0, r2;
+ if (_p != NULL && n > 0) {
+ if (sc != NULL && (sc->flag & SCONV_FROM_UTF16))
+ length = utf16nbytes(_p, n);
+ else
+ length = mbsnbytes(_p, n);
+ }
+
/* We must allocate memory even if there is no data for conversion
* or copy. This simulates archive_string_append behavior. */
- if (_p == NULL || n == 0) {
+ if (length == 0) {
int tn = 1;
if (sc != NULL && (sc->flag & SCONV_TO_UTF16))
tn = 2;
@@ -1960,16 +1967,11 @@ archive_strncat_l(struct archive_string *as, const void *_p, size_t n,
* If sc is NULL, we just make a copy.
*/
if (sc == NULL) {
- length = mbsnbytes(_p, n);
if (archive_string_append(as, _p, length) == NULL)
return (-1);/* No memory */
return (0);
}
- if (sc->flag & SCONV_FROM_UTF16)
- length = utf16nbytes(_p, n);
- else
- length = mbsnbytes(_p, n);
s = _p;
i = 0;
if (sc->nconverter > 1) {
diff --git a/libarchive/archive_write_set_format_iso9660.c b/libarchive/archive_write_set_format_iso9660.c
index 591105e65b0e..bf69c3e2ee1d 100644
--- a/libarchive/archive_write_set_format_iso9660.c
+++ b/libarchive/archive_write_set_format_iso9660.c
@@ -680,7 +680,7 @@ struct iso9660 {
/* The creation time of ISO image. */
time_t birth_time;
/* A file stream of a temporary file, which file contents
- * save to until ISO iamge can be created. */
+ * save to until ISO image can be created. */
int temp_fd;
struct isofile *cur_file;
@@ -1995,7 +1995,7 @@ iso9660_close(struct archive_write *a)
* Write an ISO 9660 image.
*/
- /* Switc to start using wbuff as file buffer. */
+ /* Switch to start using wbuff as file buffer. */
iso9660->wbuff_remaining = wb_buffmax();
iso9660->wbuff_type = WB_TO_STREAM;
iso9660->wbuff_offset = 0;
@@ -4558,7 +4558,7 @@ write_file_descriptors(struct archive_write *a)
file->cur_content = &(file->content);
do {
blocks += file->cur_content->blocks;
- /* Next fragument */
+ /* Next fragment */
file->cur_content = file->cur_content->next;
} while (file->cur_content != NULL);
}
@@ -4748,7 +4748,7 @@ isofile_gen_utility_names(struct archive_write *a, struct isofile *file)
}
/*
- * Converte a filename to UTF-16BE.
+ * Convert a filename to UTF-16BE.
*/
if (0 > archive_entry_pathname_l(file->entry, &u16, &u16len,
iso9660->sconv_to_utf16be)) {
@@ -5512,7 +5512,7 @@ isoent_setup_file_location(struct iso9660 *iso9660, int location)
file->cur_content->location = location;
location += file->cur_content->blocks;
total_block += file->cur_content->blocks;
- /* Next fragument */
+ /* Next fragment */
file->cur_content = file->cur_content->next;
} while (file->cur_content != NULL);
}
@@ -6164,7 +6164,7 @@ isoent_gen_iso9660_identifier(struct archive_write *a, struct isoent *isoent,
np->id_len = l = ext_off + np->ext_len;
/* Make an offset of the number which is used to be set
- * hexadecimal number to avoid duplicate identififier. */
+ * hexadecimal number to avoid duplicate identifier. */
if (iso9660->opt.iso_level == 1) {
if (ext_off >= 5)
noff = 5;
@@ -6742,7 +6742,7 @@ isoent_rr_move(struct archive_write *a)
int r;
pt = &(iso9660->primary.pathtbl[MAX_DEPTH-1]);
- /* Theare aren't level 8 directories reaching a deepr level. */
+ /* There aren't level 8 directories reaching a deeper level. */
if (pt->cnt == 0)
return (ARCHIVE_OK);
@@ -6813,7 +6813,7 @@ _compare_path_table(const void *v1, const void *v2)
if (cmp != 0)
return (cmp);
- /* Compare indetifier */
+ /* Compare identifier */
s1 = p1->identifier;
s2 = p2->identifier;
l = p1->ext_off;
@@ -6855,7 +6855,7 @@ _compare_path_table_joliet(const void *v1, const void *v2)
if (cmp != 0)
return (cmp);
- /* Compare indetifier */
+ /* Compare identifier */
s1 = (const unsigned char *)p1->identifier;
s2 = (const unsigned char *)p2->identifier;
l = p1->ext_off;
diff --git a/libarchive/test/CMakeLists.txt b/libarchive/test/CMakeLists.txt
index ab9a8a46d66a..3c2671dd08fc 100644
--- a/libarchive/test/CMakeLists.txt
+++ b/libarchive/test/CMakeLists.txt
@@ -169,6 +169,7 @@ IF(ENABLE_TEST)
test_read_format_zip_encryption_partially.c
test_read_format_zip_filename.c
test_read_format_zip_high_compression.c
+ test_read_format_zip_jar.c
test_read_format_zip_mac_metadata.c
test_read_format_zip_malformed.c
test_read_format_zip_msdos.c
diff --git a/libarchive/test/test_read_disk_directory_traversals.c b/libarchive/test/test_read_disk_directory_traversals.c
index 0a81e1ee434e..31eb76b93123 100644
--- a/libarchive/test/test_read_disk_directory_traversals.c
+++ b/libarchive/test/test_read_disk_directory_traversals.c
@@ -500,8 +500,8 @@ test_basic(void)
/*
* We should be on the initial directory where we performed
- * archive_read_disk_new() after we perfome archive_read_free()
- * even if we broke off the directory traversals.
+ * archive_read_disk_new() after we perform archive_read_free()
+ * even if we broke off the directory traversals.
*/
/* Save current working directory. */
@@ -1565,11 +1565,11 @@ DEFINE_TEST(test_read_disk_directory_traversals)
{
/* Basic test. */
test_basic();
- /* Test hybird mode; follow symlink initially, then not. */
+ /* Test hybrid mode; follow symlink initially, then not. */
test_symlink_hybrid();
- /* Test logcal mode; follow all symlinks. */
+ /* Test logical mode; follow all symlinks. */
test_symlink_logical();
- /* Test logcal mode; prevent loop in symlinks. */
+ /* Test logical mode; prevent loop in symlinks. */
test_symlink_logical_loop();
/* Test to restore atime. */
test_restore_atime();
diff --git a/libarchive/test/test_read_format_zip_jar.c b/libarchive/test/test_read_format_zip_jar.c
new file mode 100644
index 000000000000..ffb520eb83c1
--- /dev/null
+++ b/libarchive/test/test_read_format_zip_jar.c
@@ -0,0 +1,59 @@
+/*-
+ * Copyright (c) 2016 Peter Wu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+/*
+ * Issue 822: jar files have an empty External File Attributes field which
+ * is misinterpreted as regular file type due to OS MS-DOS.
+ */
+
+DEFINE_TEST(test_read_format_zip_jar)
+{
+ const char *refname = "test_read_format_zip_jar.jar";
+ char *p;
+ size_t s;
+ struct archive *a;
+ struct archive_entry *ae;
+ char data[16];
+
+ extract_reference_file(refname);
+ p = slurpfile(&s, refname);
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip_seekable(a));
+ assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, p, s, 1));
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("somedir/", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR | 0775, archive_entry_mode(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualIntA(a, 0, archive_read_data(a, data, 16));
+
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+ free(p);
+}
diff --git a/libarchive/test/test_read_format_zip_jar.jar.uu b/libarchive/test/test_read_format_zip_jar.jar.uu
new file mode 100644
index 000000000000..0778c931520d
--- /dev/null
+++ b/libarchive/test/test_read_format_zip_jar.jar.uu
@@ -0,0 +1,6 @@
+begin 640 test_read_format_zip_jar.jar
+M4$L#! H @ $AQETD ( 0 <V]M961I<B_^R@ 4$L!
+M @H "@ " 2'&720 @ ! '-O
+@;65D:7(O_LH %!+!08 0 ! #H J
+
+end
diff --git a/libarchive/test/test_write_disk_appledouble.c b/libarchive/test/test_write_disk_appledouble.c
index 81032fca9cd0..706794ab95bf 100644
--- a/libarchive/test/test_write_disk_appledouble.c
+++ b/libarchive/test/test_write_disk_appledouble.c
@@ -144,7 +144,7 @@ DEFINE_TEST(test_write_disk_appledouble)
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString("./file3", archive_entry_pathname(ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_extract2(a, ae, ad));
- /* Extract ._file3 which will be merged into file3 as medtadata. */
+ /* Extract ._file3 which will be merged into file3 as metadata. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString("./._file3", archive_entry_pathname(ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_extract2(a, ae, ad));
@@ -203,7 +203,7 @@ DEFINE_TEST(test_write_disk_appledouble)
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString("./file3", archive_entry_pathname(ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_extract2(a, ae, ad));
- /* Extract ._file3 which will be merged into file3 as medtadata. */
+ /* Extract ._file3 which will be merged into file3 as metadata. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString("./._file3", archive_entry_pathname(ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_extract2(a, ae, ad));
diff --git a/libarchive/test/test_write_format_xar_empty.c b/libarchive/test/test_write_format_xar_empty.c
index aa26d5d151c9..97c080887e40 100644
--- a/libarchive/test/test_write_format_xar_empty.c
+++ b/libarchive/test/test_write_format_xar_empty.c
@@ -115,6 +115,6 @@ DEFINE_TEST(test_write_format_xar_empty)
assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
- /* Verify the correct format for an empy Xar archive. */
+ /* Verify the correct format for an empty Xar archive. */
assertEqualInt(used, 0);
}
diff --git a/libarchive/test/test_write_format_zip_empty.c b/libarchive/test/test_write_format_zip_empty.c
index 2e3afec71fd3..73a55731261e 100644
--- a/libarchive/test/test_write_format_zip_empty.c
+++ b/libarchive/test/test_write_format_zip_empty.c
@@ -49,7 +49,7 @@ DEFINE_TEST(test_write_format_zip_empty)
assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
- /* Verify the correct format for an empy Zip archive. */
+ /* Verify the correct format for an empty Zip archive. */
assertEqualInt(used, 22);
assertEqualMem(buff,
"PK\005\006\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
diff --git a/libarchive/test/test_write_format_zip_empty_zip64.c b/libarchive/test/test_write_format_zip_empty_zip64.c
index d6be44a5d477..5215a716cb58 100644
--- a/libarchive/test/test_write_format_zip_empty_zip64.c
+++ b/libarchive/test/test_write_format_zip_empty_zip64.c
@@ -51,7 +51,7 @@ DEFINE_TEST(test_write_format_zip_empty_zip64)
assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
- /* Verify the correct format for an empy Zip archive with Zip64 extensions forced. */
+ /* Verify the correct format for an empty Zip archive with Zip64 extensions forced. */
assertEqualInt(used, 98);
assertEqualMem(buff,
"PK\006\006" /* Zip64 end-of-central-directory record */
diff --git a/tar/read.c b/tar/read.c
index e94cb3da8ac7..3c6cb0c13c39 100644
--- a/tar/read.c
+++ b/tar/read.c
@@ -188,18 +188,17 @@ read_archive(struct bsdtar *bsdtar, char mode, struct archive *writer)
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 read options. */
- p = (char *)malloc(sizeof(IGNORE_WRONG_MODULE_NAME)
- + strlen(reader_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 modules which are not added to
* the archive read 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 + module_len, reader_options, opt_len);
r = archive_read_set_options(a, p);
free(p);
if (r == ARCHIVE_FATAL)
diff --git a/tar/write.c b/tar/write.c
index 7960487f9d06..fb8bb92b26e9 100644
--- a/tar/write.c
+++ b/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)