From 36f3c6516a97ac526e7eb80728aa2af5b0d1f1df Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Tue, 6 Dec 2016 00:35:20 +0000 Subject: [PATCH] Update vendor/libarchive to git ddb3954bfdb9a0a98d50fb1c50cbecb603d9adf0 Vendor bugfixes: libarchive #831: Spelling fixes libarchive #832: Relax sanity checks of number fields in tar header even more OSS-Fuzz #16: Fix possible hang in uudecode_filter_read() OSS-Fuzz #220: Reject an 'ar' filename table larger than 1GB or a filename larger than 1MB. --- Makefile.am | 2 + cat/test/main.c | 4 +- cpio/test/main.c | 4 +- .../archive_read_disk_entry_from_file.c | 6 +- libarchive/archive_read_support_filter_uu.c | 9 ++- libarchive/archive_read_support_format_ar.c | 17 +++-- libarchive/archive_read_support_format_cab.c | 8 +-- libarchive/archive_read_support_format_tar.c | 17 +++-- libarchive/archive_string.c | 10 +-- libarchive/archive_string.h | 4 +- libarchive/archive_windows.c | 2 +- libarchive/archive_write_disk_windows.c | 4 +- libarchive/archive_write_set_format_7zip.c | 2 +- libarchive/archive_write_set_format_cpio.c | 2 +- .../archive_write_set_format_cpio_newc.c | 2 +- libarchive/archive_write_set_format_gnutar.c | 6 +- libarchive/archive_write_set_format_mtree.c | 4 +- libarchive/archive_write_set_format_pax.c | 2 +- libarchive/archive_write_set_format_ustar.c | 6 +- libarchive/archive_write_set_format_v7tar.c | 6 +- libarchive/archive_write_set_format_zip.c | 2 +- libarchive/test/CMakeLists.txt | 1 + libarchive/test/main.c | 4 +- libarchive/test/test_archive_cmdline.c | 8 +-- .../test/test_compat_plexus_archiver_tar.c | 69 +++++++++++++++++++ .../test_compat_plexus_archiver_tar.tar.uu | 49 +++++++++++++ 26 files changed, 192 insertions(+), 58 deletions(-) create mode 100644 libarchive/test/test_compat_plexus_archiver_tar.c create mode 100644 libarchive/test/test_compat_plexus_archiver_tar.tar.uu diff --git a/Makefile.am b/Makefile.am index 74485af962d..906f0ddf13a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -371,6 +371,7 @@ libarchive_test_SOURCES= \ libarchive/test/test_compat_mac.c \ libarchive/test/test_compat_pax_libarchive_2x.c \ libarchive/test/test_compat_perl_archive_tar.c \ + libarchive/test/test_compat_plexus_archiver_tar.c \ libarchive/test/test_compat_solaris_tar_acl.c \ libarchive/test/test_compat_solaris_pax_sparse.c \ libarchive/test/test_compat_star_acl_posix1e.c \ @@ -627,6 +628,7 @@ libarchive_test_EXTRA_DIST=\ libarchive/test/test_compat_mac-2.tar.Z.uu \ libarchive/test/test_compat_pax_libarchive_2x.tar.Z.uu \ libarchive/test/test_compat_perl_archive_tar.tar.uu \ + libarchive/test/test_compat_plexus_archiver_tar.uu \ libarchive/test/test_compat_solaris_pax_sparse_1.pax.Z.uu \ libarchive/test/test_compat_solaris_pax_sparse_2.pax.Z.uu \ libarchive/test/test_compat_solaris_tar_acl.tar.uu \ diff --git a/cat/test/main.c b/cat/test/main.c index a57984294fe..cdfdd9bd6d7 100644 --- a/cat/test/main.c +++ b/cat/test/main.c @@ -520,7 +520,7 @@ _utf8_to_unicode(uint32_t *pwc, const char *s, size_t n) return (0); /* Standard: return 0 for end-of-string. */ cnt = utf8_count[ch]; - /* Invalide sequence or there are not plenty bytes. */ + /* Invalid sequence or there are not plenty bytes. */ if (n < (size_t)cnt) return (-1); @@ -559,7 +559,7 @@ _utf8_to_unicode(uint32_t *pwc, const char *s, size_t n) return (-1); } - /* The code point larger than 0x10FFFF is not leagal + /* The code point larger than 0x10FFFF is not legal * Unicode values. */ if (wc > 0x10FFFF) return (-1); diff --git a/cpio/test/main.c b/cpio/test/main.c index 6e6b5ab435d..34282f3f8dc 100644 --- a/cpio/test/main.c +++ b/cpio/test/main.c @@ -521,7 +521,7 @@ _utf8_to_unicode(uint32_t *pwc, const char *s, size_t n) return (0); /* Standard: return 0 for end-of-string. */ cnt = utf8_count[ch]; - /* Invalide sequence or there are not plenty bytes. */ + /* Invalid sequence or there are not plenty bytes. */ if (n < (size_t)cnt) return (-1); @@ -560,7 +560,7 @@ _utf8_to_unicode(uint32_t *pwc, const char *s, size_t n) return (-1); } - /* The code point larger than 0x10FFFF is not leagal + /* The code point larger than 0x10FFFF is not legal * Unicode values. */ if (wc > 0x10FFFF) return (-1); diff --git a/libarchive/archive_read_disk_entry_from_file.c b/libarchive/archive_read_disk_entry_from_file.c index a537798f886..f37bb162a0f 100644 --- a/libarchive/archive_read_disk_entry_from_file.c +++ b/libarchive/archive_read_disk_entry_from_file.c @@ -691,7 +691,7 @@ translate_acl(struct archive_read_disk *a, #ifdef ACL_TYPE_NFS4 if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) { /* - * acl_get_entry_type_np() falis with non-NFSv4 ACLs + * acl_get_entry_type_np() fails with non-NFSv4 ACLs */ if (acl_get_entry_type_np(acl_entry, &acl_type) != 0) { archive_set_error(&a->archive, errno, "Failed " @@ -1195,7 +1195,7 @@ setup_sparse_fiemap(struct archive_read_disk *a, if (r < 0) { /* When something error happens, it is better we * should return ARCHIVE_OK because an earlier - * version(<2.6.28) cannot perfom FS_IOC_FIEMAP. */ + * version(<2.6.28) cannot perform FS_IOC_FIEMAP. */ goto exit_setup_sparse_fiemap; } if (fm->fm_mapped_extents == 0) { @@ -1355,7 +1355,7 @@ setup_sparse(struct archive_read_disk *a, goto exit_setup_sparse; } if (off_s == 0 && off_e == size) - break;/* This is not spase. */ + break;/* This is not sparse. */ archive_entry_sparse_add_entry(entry, off_s, off_e - off_s); off_s = off_e; diff --git a/libarchive/archive_read_support_filter_uu.c b/libarchive/archive_read_support_filter_uu.c index f0fc1487012..1084c415453 100644 --- a/libarchive/archive_read_support_filter_uu.c +++ b/libarchive/archive_read_support_filter_uu.c @@ -511,6 +511,13 @@ read_more: } llen = len; if ((nl == 0) && (uudecode->state != ST_UUEND)) { + if (total == 0 && ravail <= 0) { + /* There is nothing more to read, fail */ + archive_set_error(&self->archive->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Missing format data"); + return (ARCHIVE_FATAL); + } /* * Save remaining data which does not contain * NL('\n','\r'). @@ -567,7 +574,7 @@ read_more: "Insufficient compressed data"); return (ARCHIVE_FATAL); } - /* Get length of undecoded bytes of curent line. */ + /* Get length of undecoded bytes of current line. */ l = UUDECODE(*b++); body--; if (l > body) { diff --git a/libarchive/archive_read_support_format_ar.c b/libarchive/archive_read_support_format_ar.c index 4b5b66bd50a..c766cbaba7a 100644 --- a/libarchive/archive_read_support_format_ar.c +++ b/libarchive/archive_read_support_format_ar.c @@ -260,7 +260,7 @@ _ar_read_header(struct archive_read *a, struct archive_entry *entry, archive_entry_set_filetype(entry, AE_IFREG); /* Get the size of the filename table. */ number = ar_atol10(h + AR_size_offset, AR_size_size); - if (number > SIZE_MAX) { + if (number > SIZE_MAX || number > 1024 * 1024 * 1024) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Filename table too large"); return (ARCHIVE_FATAL); @@ -342,16 +342,19 @@ _ar_read_header(struct archive_read *a, struct archive_entry *entry, /* Parse the size of the name, adjust the file size. */ number = ar_atol10(h + AR_name_offset + 3, AR_name_size - 3); - bsd_name_length = (size_t)number; - /* Guard against the filename + trailing NUL - * overflowing a size_t and against the filename size - * being larger than the entire entry. */ - if (number > (uint64_t)(bsd_name_length + 1) - || (int64_t)bsd_name_length > ar->entry_bytes_remaining) { + /* Sanity check the filename length: + * = Must be <= SIZE_MAX - 1 + * = Must be <= 1MB + * = Cannot be bigger than the entire entry + */ + if (number > SIZE_MAX - 1 + || number > 1024 * 1024 + || (int64_t)number > ar->entry_bytes_remaining) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Bad input file size"); return (ARCHIVE_FATAL); } + bsd_name_length = (size_t)number; ar->entry_bytes_remaining -= bsd_name_length; /* Adjust file size reported to client. */ archive_entry_set_size(entry, ar->entry_bytes_remaining); diff --git a/libarchive/archive_read_support_format_cab.c b/libarchive/archive_read_support_format_cab.c index 099f4a83dca..2bdc1e2850e 100644 --- a/libarchive/archive_read_support_format_cab.c +++ b/libarchive/archive_read_support_format_cab.c @@ -67,7 +67,7 @@ struct lzx_dec { /* The length how many bytes we can copy decoded code from * the window. */ int copy_len; - /* Translation reversal for x86 proccessor CALL byte sequence(E8). + /* Translation reversal for x86 processor CALL byte sequence(E8). * This is used for LZX only. */ uint32_t translation_size; char translation; @@ -1555,7 +1555,7 @@ cab_read_ahead_cfdata_deflate(struct archive_read *a, ssize_t *avail) /* * Note: I suspect there is a bug in makecab.exe because, in rare * case, compressed bytes are still remaining regardless we have - * gotten all uncompressed bytes, which size is recoded in CFDATA, + * gotten all uncompressed bytes, which size is recorded in CFDATA, * as much as we need, and we have to use the garbage so as to * correctly compute the sum of CFDATA accordingly. */ @@ -1742,7 +1742,7 @@ cab_read_ahead_cfdata_lzx(struct archive_read *a, ssize_t *avail) } /* - * Translation reversal of x86 proccessor CALL byte sequence(E8). + * Translation reversal of x86 processor CALL byte sequence(E8). */ lzx_translation(&cab->xstrm, cab->uncompressed_buffer, cfdata->uncompressed_size, @@ -2271,7 +2271,7 @@ static int lzx_br_fillup(struct lzx_stream *strm, struct lzx_br *br) { /* - * x86 proccessor family can read misaligned data without an access error. + * x86 processor family can read misaligned data without an access error. */ int n = CACHE_BITS - br->cache_avail; diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c index 071d766b74b..6febc2dd28b 100644 --- a/libarchive/archive_read_support_format_tar.c +++ b/libarchive/archive_read_support_format_tar.c @@ -299,14 +299,21 @@ archive_read_format_tar_cleanup(struct archive_read *a) * * This has to be pretty lenient in order to accomodate the enormous * variety of tar writers in the world: - * = POSIX ustar requires octal values with leading zeros and - * specific termination on fields + * = POSIX (IEEE Std 1003.1-1988) ustar requires octal values with leading + * zeros and allows fields to be terminated with space or null characters * = Many writers use different termination (in particular, libarchive * omits terminator bytes to squeeze one or two more digits) * = Many writers pad with space and omit leading zeros * = GNU tar and star write base-256 values if numbers are too * big to be represented in octal * + * Examples of specific tar headers that we should support: + * = Perl Archive::Tar terminates uid, gid, devminor and devmajor with two + * null bytes, pads size with spaces and other numeric fields with zeroes + * = plexus-archiver prior to 2.6.3 (before switching to commons-compress) + * may have uid and gid fields filled with spaces without any octal digits + * at all and pads all numeric fields with spaces + * * This should tolerate all variants in use. It will reject a field * where the writer just left garbage after a trailing NUL. */ @@ -324,11 +331,7 @@ validate_number_field(const char* p_field, size_t i_size) while (i < i_size && p_field[i] == ' ') { ++i; } - /* Must be at least one octal digit. */ - if (i >= i_size || p_field[i] < '0' || p_field[i] > '7') { - return 0; - } - /* Skip remaining octal digits. */ + /* Skip octal digits. */ while (i < i_size && p_field[i] >= '0' && p_field[i] <= '7') { ++i; } diff --git a/libarchive/archive_string.c b/libarchive/archive_string.c index 33094f47612..727b9e886d3 100644 --- a/libarchive/archive_string.c +++ b/libarchive/archive_string.c @@ -2298,7 +2298,7 @@ _utf8_to_unicode(uint32_t *pwc, const char *s, size_t n) return (0); /* Standard: return 0 for end-of-string. */ cnt = utf8_count[ch]; - /* Invalide sequence or there are not plenty bytes. */ + /* Invalid sequence or there are not plenty bytes. */ if ((int)n < cnt) { cnt = (int)n; for (i = 1; i < cnt; i++) { @@ -2379,7 +2379,7 @@ _utf8_to_unicode(uint32_t *pwc, const char *s, size_t n) goto invalid_sequence; } - /* The code point larger than 0x10FFFF is not leagal + /* The code point larger than 0x10FFFF is not legal * Unicode values. */ if (wc > UNICODE_MAX) goto invalid_sequence; @@ -2397,7 +2397,7 @@ utf8_to_unicode(uint32_t *pwc, const char *s, size_t n) int cnt; cnt = _utf8_to_unicode(pwc, s, n); - /* Any of Surrogate pair is not leagal Unicode values. */ + /* Any of Surrogate pair is not legal Unicode values. */ if (cnt == 3 && IS_SURROGATE_PAIR_LA(*pwc)) return (-3); return (cnt); @@ -2458,7 +2458,7 @@ invalid_sequence: /* * Convert a Unicode code point to a single UTF-8 sequence. * - * NOTE:This function does not check if the Unicode is leagal or not. + * NOTE:This function does not check if the Unicode is legal or not. * Please you definitely check it before calling this. */ static size_t @@ -2554,7 +2554,7 @@ utf16_to_unicode(uint32_t *pwc, const char *s, size_t n, int be) * Surrogate pair values(0xd800 through 0xdfff) are only * used by UTF-16, so, after above culculation, the code * must not be surrogate values, and Unicode has no codes - * larger than 0x10ffff. Thus, those are not leagal Unicode + * larger than 0x10ffff. Thus, those are not legal Unicode * values. */ if (IS_SURROGATE_PAIR_LA(uc) || uc > UNICODE_MAX) { diff --git a/libarchive/archive_string.h b/libarchive/archive_string.h index 23f49165749..bac22e6d294 100644 --- a/libarchive/archive_string.h +++ b/libarchive/archive_string.h @@ -115,13 +115,13 @@ archive_string_conversion_set_opt(struct archive_string_conv *, int); /* Copy one archive_string to another in locale conversion. - * Return -1 if conversion failes. */ + * Return -1 if conversion fails. */ int archive_strncpy_l(struct archive_string *, const void *, size_t, struct archive_string_conv *); /* Copy one archive_string to another in locale conversion. - * Return -1 if conversion failes. */ + * Return -1 if conversion fails. */ int archive_strncat_l(struct archive_string *, const void *, size_t, struct archive_string_conv *); diff --git a/libarchive/archive_windows.c b/libarchive/archive_windows.c index d4e93fe78aa..d53906324f7 100644 --- a/libarchive/archive_windows.c +++ b/libarchive/archive_windows.c @@ -766,7 +766,7 @@ __la_win_entry_in_posix_pathseparator(struct archive_entry *entry) has_backslash = 1; } /* - * If there is no backslach chars, return the original. + * If there is no backslash chars, return the original. */ if (!has_backslash) return (entry); diff --git a/libarchive/archive_write_disk_windows.c b/libarchive/archive_write_disk_windows.c index da76c54db5b..4e7a664a2bc 100644 --- a/libarchive/archive_write_disk_windows.c +++ b/libarchive/archive_write_disk_windows.c @@ -192,7 +192,7 @@ struct archive_write_disk { /* * Default mode for dirs created automatically (will be modified by umask). - * Note that POSIX specifies 0777 for implicity-created dirs, "modified + * Note that POSIX specifies 0777 for implicitly-created dirs, "modified * by the process' file creation mask." */ #define DEFAULT_DIR_MODE 0777 @@ -396,7 +396,7 @@ permissive_name_w(struct archive_write_disk *a) } /* - * A full-pathname pointig a network drive + * A full-pathname pointing to a network drive * like "\\\\file". */ if (wnp[0] == L'\\' && wnp[1] == L'\\' && wnp[2] != L'\\') { diff --git a/libarchive/archive_write_set_format_7zip.c b/libarchive/archive_write_set_format_7zip.c index fc6ccfe0ba8..abd521a4641 100644 --- a/libarchive/archive_write_set_format_7zip.c +++ b/libarchive/archive_write_set_format_7zip.c @@ -205,7 +205,7 @@ struct _7zip { /* * The list of the file entries which has its contents is used to * manage struct file objects. - * We use 'next' a menber of struct file to chain. + * We use 'next' (a member of struct file) to chain. */ struct { struct file *first; diff --git a/libarchive/archive_write_set_format_cpio.c b/libarchive/archive_write_set_format_cpio.c index 352649365d6..a4c9d1ed276 100644 --- a/libarchive/archive_write_set_format_cpio.c +++ b/libarchive/archive_write_set_format_cpio.c @@ -289,7 +289,7 @@ write_header(struct archive_write *a, struct archive_entry *entry) sconv = get_sconv(a); #if defined(_WIN32) && !defined(__CYGWIN__) - /* Make sure the path separators in pahtname, hardlink and symlink + /* Make sure the path separators in pathname, hardlink and symlink * are all slash '/', not the Windows path separator '\'. */ entry_main = __la_win_entry_in_posix_pathseparator(entry); if (entry_main == NULL) { diff --git a/libarchive/archive_write_set_format_cpio_newc.c b/libarchive/archive_write_set_format_cpio_newc.c index a9bfa808cc1..54b5576ca25 100644 --- a/libarchive/archive_write_set_format_cpio_newc.c +++ b/libarchive/archive_write_set_format_cpio_newc.c @@ -232,7 +232,7 @@ write_header(struct archive_write *a, struct archive_entry *entry) sconv = get_sconv(a); #if defined(_WIN32) && !defined(__CYGWIN__) - /* Make sure the path separators in pahtname, hardlink and symlink + /* Make sure the path separators in pathname, hardlink and symlink * are all slash '/', not the Windows path separator '\'. */ entry_main = __la_win_entry_in_posix_pathseparator(entry); if (entry_main == NULL) { diff --git a/libarchive/archive_write_set_format_gnutar.c b/libarchive/archive_write_set_format_gnutar.c index 1d635d2dc3d..a9c41236ee6 100644 --- a/libarchive/archive_write_set_format_gnutar.c +++ b/libarchive/archive_write_set_format_gnutar.c @@ -119,9 +119,9 @@ static const char template_header[] = { '0','0','0','0','0','0', '0','\0', /* gid, null termination: 8 bytes */ '0','0','0','0','0','0', '0','\0', - /* size, space termation: 12 bytes */ + /* size, space termination: 12 bytes */ '0','0','0','0','0','0','0','0','0','0','0', '\0', - /* mtime, space termation: 12 bytes */ + /* mtime, space termination: 12 bytes */ '0','0','0','0','0','0','0','0','0','0','0', '\0', /* Initial checksum value: 8 spaces */ ' ',' ',' ',' ',' ',' ',' ',' ', @@ -368,7 +368,7 @@ archive_write_gnutar_header(struct archive_write *a, } #if defined(_WIN32) && !defined(__CYGWIN__) - /* Make sure the path separators in pahtname, hardlink and symlink + /* Make sure the path separators in pathname, hardlink and symlink * are all slash '/', not the Windows path separator '\'. */ entry_main = __la_win_entry_in_posix_pathseparator(entry); if (entry_main == NULL) { diff --git a/libarchive/archive_write_set_format_mtree.c b/libarchive/archive_write_set_format_mtree.c index b686303d9a4..493d4735661 100644 --- a/libarchive/archive_write_set_format_mtree.c +++ b/libarchive/archive_write_set_format_mtree.c @@ -1840,9 +1840,9 @@ mtree_entry_setup_filenames(struct archive_write *a, struct mtree_entry *file, len = strlen(p); /* - * Add "./" prefiex. + * Add "./" prefix. * NOTE: If the pathname does not have a path separator, we have - * to add "./" to the head of the pathename because mtree reader + * to add "./" to the head of the pathname because mtree reader * will suppose that it is v1(a.k.a classic) mtree format and * change the directory unexpectedly and so it will make a wrong * path. diff --git a/libarchive/archive_write_set_format_pax.c b/libarchive/archive_write_set_format_pax.c index 6f7fe783900..30fd6df1154 100644 --- a/libarchive/archive_write_set_format_pax.c +++ b/libarchive/archive_write_set_format_pax.c @@ -709,7 +709,7 @@ archive_write_pax_header(struct archive_write *a, /* Copy entry so we can modify it as needed. */ #if defined(_WIN32) && !defined(__CYGWIN__) - /* Make sure the path separators in pahtname, hardlink and symlink + /* Make sure the path separators in pathname, hardlink and symlink * are all slash '/', not the Windows path separator '\'. */ entry_main = __la_win_entry_in_posix_pathseparator(entry_original); if (entry_main == entry_original) diff --git a/libarchive/archive_write_set_format_ustar.c b/libarchive/archive_write_set_format_ustar.c index 797b5334bd4..b475f45f145 100644 --- a/libarchive/archive_write_set_format_ustar.c +++ b/libarchive/archive_write_set_format_ustar.c @@ -114,9 +114,9 @@ static const char template_header[] = { '0','0','0','0','0','0', ' ','\0', /* gid, space-null termination: 8 bytes */ '0','0','0','0','0','0', ' ','\0', - /* size, space termation: 12 bytes */ + /* size, space termination: 12 bytes */ '0','0','0','0','0','0','0','0','0','0','0', ' ', - /* mtime, space termation: 12 bytes */ + /* mtime, space termination: 12 bytes */ '0','0','0','0','0','0','0','0','0','0','0', ' ', /* Initial checksum value: 8 spaces */ ' ',' ',' ',' ',' ',' ',' ',' ', @@ -336,7 +336,7 @@ archive_write_ustar_header(struct archive_write *a, struct archive_entry *entry) } #if defined(_WIN32) && !defined(__CYGWIN__) - /* Make sure the path separators in pahtname, hardlink and symlink + /* Make sure the path separators in pathname, hardlink and symlink * are all slash '/', not the Windows path separator '\'. */ entry_main = __la_win_entry_in_posix_pathseparator(entry); if (entry_main == NULL) { diff --git a/libarchive/archive_write_set_format_v7tar.c b/libarchive/archive_write_set_format_v7tar.c index 17efbaf753f..a6ca158df7d 100644 --- a/libarchive/archive_write_set_format_v7tar.c +++ b/libarchive/archive_write_set_format_v7tar.c @@ -98,9 +98,9 @@ static const char template_header[] = { '0','0','0','0','0','0', ' ','\0', /* gid, space-null termination: 8 bytes */ '0','0','0','0','0','0', ' ','\0', - /* size, space termation: 12 bytes */ + /* size, space termination: 12 bytes */ '0','0','0','0','0','0','0','0','0','0','0', ' ', - /* mtime, space termation: 12 bytes */ + /* mtime, space termination: 12 bytes */ '0','0','0','0','0','0','0','0','0','0','0', ' ', /* Initial checksum value: 8 spaces */ ' ',' ',' ',' ',' ',' ',' ',' ', @@ -314,7 +314,7 @@ archive_write_v7tar_header(struct archive_write *a, struct archive_entry *entry) } #if defined(_WIN32) && !defined(__CYGWIN__) - /* Make sure the path separators in pahtname, hardlink and symlink + /* Make sure the path separators in pathname, hardlink and symlink * are all slash '/', not the Windows path separator '\'. */ entry_main = __la_win_entry_in_posix_pathseparator(entry); if (entry_main == NULL) { diff --git a/libarchive/archive_write_set_format_zip.c b/libarchive/archive_write_set_format_zip.c index e4edb818819..810b8d7ffd7 100644 --- a/libarchive/archive_write_set_format_zip.c +++ b/libarchive/archive_write_set_format_zip.c @@ -592,7 +592,7 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) #if defined(_WIN32) && !defined(__CYGWIN__) - /* Make sure the path separators in pahtname, hardlink and symlink + /* Make sure the path separators in pathname, hardlink and symlink * are all slash '/', not the Windows path separator '\'. */ zip->entry = __la_win_entry_in_posix_pathseparator(entry); if (zip->entry == entry) diff --git a/libarchive/test/CMakeLists.txt b/libarchive/test/CMakeLists.txt index 5dad2191021..ab9a8a46d66 100644 --- a/libarchive/test/CMakeLists.txt +++ b/libarchive/test/CMakeLists.txt @@ -59,6 +59,7 @@ IF(ENABLE_TEST) test_compat_mac.c test_compat_pax_libarchive_2x.c test_compat_perl_archive_tar.c + test_compat_plexus_archiver_tar.c test_compat_solaris_pax_sparse.c test_compat_solaris_tar_acl.c test_compat_star_acl_posix1e.c diff --git a/libarchive/test/main.c b/libarchive/test/main.c index 32a1f78b9cf..3553be6a992 100644 --- a/libarchive/test/main.c +++ b/libarchive/test/main.c @@ -519,7 +519,7 @@ _utf8_to_unicode(uint32_t *pwc, const char *s, size_t n) return (0); /* Standard: return 0 for end-of-string. */ cnt = utf8_count[ch]; - /* Invalide sequence or there are not plenty bytes. */ + /* Invalid sequence or there are not plenty bytes. */ if (n < (size_t)cnt) return (-1); @@ -558,7 +558,7 @@ _utf8_to_unicode(uint32_t *pwc, const char *s, size_t n) return (-1); } - /* The code point larger than 0x10FFFF is not leagal + /* The code point larger than 0x10FFFF is not legal * Unicode values. */ if (wc > 0x10FFFF) return (-1); diff --git a/libarchive/test/test_archive_cmdline.c b/libarchive/test/test_archive_cmdline.c index a411821356c..a8236105af0 100644 --- a/libarchive/test/test_archive_cmdline.c +++ b/libarchive/test/test_archive_cmdline.c @@ -66,7 +66,7 @@ DEFINE_TEST(test_archive_cmdline) assertEqualString("gzip", cl->argv[0]); assertEqualInt(ARCHIVE_OK, __archive_cmdline_free(cl)); - /* A command line includes space characer. */ + /* A command line includes space character. */ assert((cl = __archive_cmdline_allocate()) != NULL); if (cl == NULL) return; @@ -78,7 +78,7 @@ DEFINE_TEST(test_archive_cmdline) assertEqualString("gzip ", cl->argv[0]); assertEqualInt(ARCHIVE_OK, __archive_cmdline_free(cl)); - /* A command line includes space characer: pattern 2.*/ + /* A command line includes space character: pattern 2.*/ assert((cl = __archive_cmdline_allocate()) != NULL); if (cl == NULL) return; @@ -90,7 +90,7 @@ DEFINE_TEST(test_archive_cmdline) assertEqualString("gzip x", cl->argv[0]); assertEqualInt(ARCHIVE_OK, __archive_cmdline_free(cl)); - /* A command line includes space characer: pattern 3.*/ + /* A command line includes space character: pattern 3.*/ assert((cl = __archive_cmdline_allocate()) != NULL); if (cl == NULL) return; @@ -103,7 +103,7 @@ DEFINE_TEST(test_archive_cmdline) assertEqualString("gzip x s ", cl->argv[0]); assertEqualInt(ARCHIVE_OK, __archive_cmdline_free(cl)); - /* A command line includes space characer: pattern 4.*/ + /* A command line includes space character: pattern 4.*/ assert((cl = __archive_cmdline_allocate()) != NULL); if (cl == NULL) return; diff --git a/libarchive/test/test_compat_plexus_archiver_tar.c b/libarchive/test/test_compat_plexus_archiver_tar.c new file mode 100644 index 00000000000..0f8bedc2df5 --- /dev/null +++ b/libarchive/test/test_compat_plexus_archiver_tar.c @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 2016 Martin Matuska + * 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"); + +/* + * Verify our ability to read sample files created by plexus-archiver version + * 2.6.2 and lower (project switched to Apache Commons Compress with 2.6.3). + * + * These files may have tar entries with uid and gid header fields filled with + * spaces without any octal digit. + */ + +DEFINE_TEST(test_compat_plexus_archiver_tar) +{ + char name[] = "test_compat_plexus_archiver_tar.tar"; + struct archive_entry *ae; + struct archive *a; + int r; + + assert((a = archive_read_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + extract_reference_file(name); + assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, + 10240)); + + /* Read first entry. */ + assertEqualIntA(a, ARCHIVE_OK, r = archive_read_next_header(a, &ae)); + if (r != ARCHIVE_OK) { + archive_read_free(a); + return; + } + assertEqualString("commons-logging-1.2/NOTICE.txt", + archive_entry_pathname(ae)); + assertEqualInt(1404583896, archive_entry_mtime(ae)); + assertEqualInt(0100664, archive_entry_mode(ae)); + assertEqualInt(0, archive_entry_uid(ae)); + assertEqualInt(0, archive_entry_gid(ae)); + + /* Verify that the format detection worked. */ + assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_NONE); + assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); + + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} diff --git a/libarchive/test/test_compat_plexus_archiver_tar.tar.uu b/libarchive/test/test_compat_plexus_archiver_tar.tar.uu new file mode 100644 index 00000000000..39d7b11d1b6 --- /dev/null +++ b/libarchive/test/test_compat_plexus_archiver_tar.tar.uu @@ -0,0 +1,49 @@ +begin 644 test_compat_plexus_archiver_tar.tar +M8V]M;6]N