From f31a5a02722adc67186a86b300ec88eb5c687dfb Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Mon, 1 Jul 2013 17:12:24 +0200 Subject: [PATCH] Detect encrypted archive entries (ZIP, RAR, 7Zip) With this change you can detect if an archive entry is encrypted. The archive formats covered with this change are: ZIP, RAR, and 7zip. Other formats can be added quite simply by looking at the already supported formats. For all the already supported formats we have tests that check if: * an archive entries's data is encryped (data test) * an archive entries's metadata is encrypted (header test) * one file is encrypted while another is not (partially test) These new functions are introduced. int archive_read_format_capabilities(struct archive*) Returns a bitmask of capabilities that are supported by the archive format reader. If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned; otherwise 0 is returned. You can call this function even before reading the first header from an archive. Return Values: * ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA The reader supports detection of encrypted data. * ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA The reader supports detection of encrypted metadata (e.g. filename, modification time, size, etc.) * ARCHIVE_READ_FORMAT_CAPS_NONE None of the above capabilities. If this value is returned, this doesn't mean that the format itself doesn't support any type of encryption it simply means that the reader is not capable of detecting it. int archive_read_has_encrypted_entries(struct archive *) Returns "true" (non-zero) if the archive contains at least one encrypted entry, no matter which encryption type (data or metadata) is used; otherwise 0 is returned. You should only call this function after reading the first header from an archive. NOTE: I'm not sure that this function will stay in for long. int archive_entry_is_data_encrypted(struct archive_entry*) Returns "true" (non-zero) if the archive entry's data is encrypted; otherwise 0 is returned. You can call this function after calling archive_read_next_header(). int archive_entry_is_metadata_encrypted(struct archive_entry*) Returns "true" (non-zero) if the archive entry's metadata is encrypted; otherwise 0 is returned. You can call this function after calling archive_read_next_header(). int archive_entry_is_encrypted(struct archive_entry*) Returns "true" (non-zero) if either the archive entry's data and/or it's metadata is encrypted; otherwise 0 is returned. You can call this function after calling archive_read_next_header(). If you use archive_read_format_capabilities() in combination with one of the archive_entry_is_[data|metadata]_encrypted() functions, you can be sure that you've encountered an encrypted entry. This allows you to react differently depending on libarchive's return codes. For instance, you might want to skip encrypted files from being extracted until decryption support has been implemented. Here's how I generated the 7zip test files: ------------------------------------------- With header encrpytion (-mhe=on): $ rm -f test_read_format_7zip_encryption_header.7z $ echo "foo" > bar.txt && 7z a -mhe=on -p12345678 \ test_read_format_7zip_encryption_header.7z bar.txt $ uuencode test_read_format_7zip_encryption_header.7z \ test_read_format_7zip_encryption_header.7z > \ test_read_format_7zip_encryption_header.7z.uu Without header encrpytion (-mhe=off): $ rm -f test_read_format_7zip_encryption.7z $ echo "foo" > bar.txt && 7z a -mhe=off -p12345678 \ test_read_format_7zip_encryption.7z bar.txt $ uuencode test_read_format_7zip_encryption.7z \ test_read_format_7zip_encryption.7z > \ test_read_format_7zip_encryption.7z.uu Partially encrypted archive: $ rm -f test_read_format_7zip_encryption_partially.7z $ echo "foo" > bar_unencrypted.txt && 7z a \ test_read_format_7zip_encryption_partially.7z bar_unencrypted.txt $ echo "foo" > bar_encrypted.txt && 7z a -mhe=off -p12345678 \ test_read_format_7zip_encryption_partially.7z bar_encrypted.txt $ uuencode test_read_format_7zip_encryption_partially.7z \ test_read_format_7zip_encryption_partially.7z > \ test_read_format_7zip_encryption_partially.7z.uu Here's how I generated the RAR test files: ------------------------------------------ These are the files we can will add to the archives: echo "data of foo.txt" > foo.txt echo "data of bar.txt" > bar.txt With header encrpytion (-hp): rm -f test_read_format_rar_encryption_header.rar rar a -hp12345678 test_read_format_rar_encryption_header.rar \ foo.txt bar.txt uuencode test_read_format_rar_encryption_header.rar \ test_read_format_rar_encryption_header.rar > \ test_read_format_rar_encryption_header.rar.uu Without header encrpytion (-p): rm -f test_read_format_rar_encryption_data.rar rar a -p12345678 test_read_format_rar_encryption_data.rar \ foo.txt bar.txt uuencode test_read_format_rar_encryption_data.rar \ test_read_format_rar_encryption_data.rar > \ test_read_format_rar_encryption_data.rar.uu Partially encrypted archive (-p on "foo.txt" and no password on "bar.txt"): rm -f test_read_format_rar_encryption_partially.rar rar a -p12345678 test_read_format_rar_encryption_partially.rar foo.txt rar a test_read_format_rar_encryption_partially.rar bar.txt uuencode test_read_format_rar_encryption_partially.rar \ test_read_format_rar_encryption_partially.rar > \ test_read_format_rar_encryption_partially.rar.uu Here's how I generated the ZIP test files: ------------------------------------------ This is how I've created the test files: These are the files we will add to the archives: On Windows: echo "data of foo.txt" > foo.txt echo "data of bar.txt" > bar.txt For the creation of the Zip archives I've used the PKZIP Command Line Add-On available from here: http://comm.pkware.com/pkzip-cli-download.html With header (aka central directory) encrpytion (-cd): On Windows: del /F test_read_format_zip_encryption_header.zip pkzipc.exe -add -cryptalgorithm=AES,256 -passphrase=12345678 -cd test_read_format_zip_encryption_header.zip foo.txt bar.txt On Linux: uuencode test_read_format_zip_encryption_header.zip \ test_read_format_zip_encryption_header.zip > \ test_read_format_zip_encryption_header.zip.uu Without header encrpytion: On Windows: del /F test_read_format_zip_encryption_data.zip pkzipc.exe -add -cryptalgorithm=AES,256 -passphrase=12345678 test_read_format_zip_encryption_data.zip foo.txt bar.txt On Linux: uuencode test_read_format_zip_encryption_data.zip \ test_read_format_zip_encryption_data.zip > \ test_read_format_zip_encryption_data.zip.uu Partially encrypted archive ("foo.txt" is encrypted and "bar.txt" is not): On Windows: del /F test_read_format_zip_encryption_partially.zip pkzipc.exe -add -cryptalgorithm=AES,256 -passphrase=12345678 test_read_format_zip_encryption_partially.zip foo.txt pkzipc.exe -add test_read_format_zip_encryption_partially.zip bar.txt On Linux: uuencode test_read_format_zip_encryption_partially.zip \ test_read_format_zip_encryption_partially.zip > \ test_read_format_zip_encryption_partially.zip.uu --- libarchive/archive.h | 21 +++ libarchive/archive_entry.c | 39 +++++ libarchive/archive_entry.h | 5 + libarchive/archive_entry_private.h | 3 + libarchive/archive_read.c | 31 +++- libarchive/archive_read_private.h | 6 +- libarchive/archive_read_support_format_7zip.c | 98 +++++++++-- libarchive/archive_read_support_format_ar.c | 4 +- libarchive/archive_read_support_format_cab.c | 4 +- libarchive/archive_read_support_format_cpio.c | 4 +- .../archive_read_support_format_empty.c | 2 + .../archive_read_support_format_iso9660.c | 4 +- libarchive/archive_read_support_format_lha.c | 4 +- .../archive_read_support_format_mtree.c | 2 +- libarchive/archive_read_support_format_rar.c | 46 +++++- libarchive/archive_read_support_format_raw.c | 4 +- libarchive/archive_read_support_format_tar.c | 4 +- libarchive/archive_read_support_format_xar.c | 4 +- libarchive/archive_read_support_format_zip.c | 92 ++++++++--- libarchive/test/CMakeLists.txt | 9 + libarchive/test/test_read_format_7zip.c | 54 ++++++ .../test_read_format_7zip_encryption.7z.uu | 7 + .../test_read_format_7zip_encryption_data.c | 68 ++++++++ ...t_read_format_7zip_encryption_header.7z.uu | 8 + .../test_read_format_7zip_encryption_header.c | 71 ++++++++ ...ead_format_7zip_encryption_partially.7z.uu | 8 + ...st_read_format_7zip_encryption_partially.c | 79 +++++++++ libarchive/test/test_read_format_ar.c | 6 + libarchive/test/test_read_format_cab.c | 22 +++ .../test/test_read_format_cab_filename.c | 8 + libarchive/test/test_read_format_cpio_afio.c | 4 + libarchive/test/test_read_format_cpio_bin.c | 2 + libarchive/test/test_read_format_cpio_bin_Z.c | 2 + .../test/test_read_format_cpio_bin_be.c | 2 + .../test/test_read_format_cpio_bin_bz2.c | 2 + .../test/test_read_format_cpio_bin_gz.c | 2 + .../test/test_read_format_cpio_bin_lzip.c | 2 + .../test/test_read_format_cpio_bin_lzma.c | 2 + .../test/test_read_format_cpio_bin_xz.c | 2 + .../test/test_read_format_cpio_filename.c | 4 + libarchive/test/test_read_format_cpio_odc.c | 2 + .../test_read_format_cpio_svr4_bzip2_rpm.c | 2 + .../test/test_read_format_cpio_svr4_gzip.c | 2 + .../test_read_format_cpio_svr4_gzip_rpm.c | 2 + .../test/test_read_format_cpio_svr4c_Z.c | 2 + libarchive/test/test_read_format_empty.c | 2 + .../test/test_read_format_gtar_filename.c | 2 + libarchive/test/test_read_format_gtar_gz.c | 2 + libarchive/test/test_read_format_gtar_lzma.c | 2 + .../test/test_read_format_gtar_sparse.c | 2 + libarchive/test/test_read_format_iso_Z.c | 4 + .../test/test_read_format_iso_multi_extent.c | 2 + .../test/test_read_format_iso_xorriso.c | 3 + .../test/test_read_format_isojoliet_bz2.c | 6 + .../test/test_read_format_isojoliet_long.c | 8 + .../test/test_read_format_isojoliet_rr.c | 10 ++ .../test_read_format_isojoliet_versioned.c | 4 + libarchive/test/test_read_format_isorr_bz2.c | 3 + libarchive/test/test_read_format_isorr_ce.c | 3 + .../test/test_read_format_isorr_new_bz2.c | 3 + .../test/test_read_format_isorr_rr_moved.c | 3 + .../test/test_read_format_isozisofs_bz2.c | 3 + libarchive/test/test_read_format_lha.c | 16 ++ .../test/test_read_format_lha_filename.c | 5 +- libarchive/test/test_read_format_mtree.c | 94 ++++++++++- libarchive/test/test_read_format_pax_bz2.c | 2 + libarchive/test/test_read_format_rar.c | 154 ++++++++++++++++++ .../test_read_format_rar_encryption_data.c | 79 +++++++++ ...est_read_format_rar_encryption_data.rar.uu | 8 + .../test_read_format_rar_encryption_header.c | 69 ++++++++ ...t_read_format_rar_encryption_header.rar.uu | 8 + ...est_read_format_rar_encryption_partially.c | 79 +++++++++ ...ead_format_rar_encryption_partially.rar.uu | 7 + libarchive/test/test_read_format_raw.c | 4 + libarchive/test/test_read_format_tar.c | 4 + .../test_read_format_tar_empty_filename.c | 2 + .../test/test_read_format_tar_empty_pax.c | 2 + .../test/test_read_format_tar_filename.c | 31 ++++ libarchive/test/test_read_format_tbz.c | 2 + libarchive/test/test_read_format_tgz.c | 2 + libarchive/test/test_read_format_tlz.c | 2 + libarchive/test/test_read_format_txz.c | 2 + libarchive/test/test_read_format_tz.c | 2 + .../test/test_read_format_ustar_filename.c | 40 ++++- libarchive/test/test_read_format_xar.c | 2 + libarchive/test/test_read_format_zip.c | 14 ++ .../test_read_format_zip_comment_stored.c | 6 + .../test_read_format_zip_encryption_data.c | 79 +++++++++ ...est_read_format_zip_encryption_data.zip.uu | 25 +++ .../test_read_format_zip_encryption_header.c | 69 ++++++++ ...t_read_format_zip_encryption_header.zip.uu | 32 ++++ ...est_read_format_zip_encryption_partially.c | 79 +++++++++ ...ead_format_zip_encryption_partially.zip.uu | 18 ++ .../test/test_read_format_zip_filename.c | 84 ++++++++++ .../test/test_read_format_zip_mac_metadata.c | 2 + libarchive/test/test_read_format_zip_sfx.c | 4 + 96 files changed, 1794 insertions(+), 47 deletions(-) create mode 100644 libarchive/test/test_read_format_7zip_encryption.7z.uu create mode 100644 libarchive/test/test_read_format_7zip_encryption_data.c create mode 100644 libarchive/test/test_read_format_7zip_encryption_header.7z.uu create mode 100644 libarchive/test/test_read_format_7zip_encryption_header.c create mode 100644 libarchive/test/test_read_format_7zip_encryption_partially.7z.uu create mode 100644 libarchive/test/test_read_format_7zip_encryption_partially.c create mode 100644 libarchive/test/test_read_format_rar_encryption_data.c create mode 100644 libarchive/test/test_read_format_rar_encryption_data.rar.uu create mode 100644 libarchive/test/test_read_format_rar_encryption_header.c create mode 100644 libarchive/test/test_read_format_rar_encryption_header.rar.uu create mode 100644 libarchive/test/test_read_format_rar_encryption_partially.c create mode 100644 libarchive/test/test_read_format_rar_encryption_partially.rar.uu create mode 100644 libarchive/test/test_read_format_zip_encryption_data.c create mode 100644 libarchive/test/test_read_format_zip_encryption_data.zip.uu create mode 100644 libarchive/test/test_read_format_zip_encryption_header.c create mode 100644 libarchive/test/test_read_format_zip_encryption_header.zip.uu create mode 100644 libarchive/test/test_read_format_zip_encryption_partially.c create mode 100644 libarchive/test/test_read_format_zip_encryption_partially.zip.uu diff --git a/libarchive/archive.h b/libarchive/archive.h index 528144030..0d3ed8f40 100644 --- a/libarchive/archive.h +++ b/libarchive/archive.h @@ -285,6 +285,18 @@ typedef int archive_switch_callback(struct archive *, void *_client_data1, #define ARCHIVE_FORMAT_RAR 0xD0000 #define ARCHIVE_FORMAT_7ZIP 0xE0000 +/* + * Codes returned by archive_read_format_capabilities(). + * + * This list can be extended with values between 0 and 0xffff. + * The original purpose of this list was to let different archive + * format readers expose their general capabilities in terms of + * encryption. + */ +#define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */ +#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0) /* reader can detect encrypted data */ +#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1) /* reader can detect encryptable metadata (pathname, mtime, etc.) */ + /*- * Basic outline for reading an archive: * 1) Ask archive_read_new for an archive reader object. @@ -466,6 +478,15 @@ __LA_DECL int archive_read_next_header2(struct archive *, */ __LA_DECL __LA_INT64_T archive_read_header_position(struct archive *); +/* Returns "true" (non-zero) if the archive contains encrypted entries; otherwise 0 is returned. */ +__LA_DECL int archive_read_has_encrypted_entries(struct archive *); + +/* + * Returns a bitmask of capabilities that are supported by the archive format reader. + * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned. + */ +__LA_DECL int archive_read_format_capabilities(struct archive *); + /* Read data from the body of an entry. Similar to read(2). */ __LA_DECL __LA_SSIZE_T archive_read_data(struct archive *, void *, size_t); diff --git a/libarchive/archive_entry.c b/libarchive/archive_entry.c index 386e51d47..101e61f1e 100644 --- a/libarchive/archive_entry.c +++ b/libarchive/archive_entry.c @@ -201,6 +201,10 @@ archive_entry_clone(struct archive_entry *entry) entry2->ae_set = entry->ae_set; archive_mstring_copy(&entry2->ae_uname, &entry->ae_uname); + /* Copy encryption status */ + entry2->is_data_encrypted = entry->is_data_encrypted; + entry2->is_metadata_encrypted = entry->is_metadata_encrypted; + /* Copy ACL data over. */ archive_acl_copy(&entry2->acl, &entry->acl); @@ -695,6 +699,25 @@ _archive_entry_uname_l(struct archive_entry *entry, return (archive_mstring_get_mbs_l(&entry->ae_uname, p, len, sc)); } +int +archive_entry_is_data_encrypted(struct archive_entry *entry) +{ + return (entry && entry->is_data_encrypted); +} + +int +archive_entry_is_metadata_encrypted(struct archive_entry *entry) +{ + return (entry && entry->is_metadata_encrypted); +} + +int +archive_entry_is_encrypted(struct archive_entry *entry) +{ + return (entry && (entry->is_data_encrypted + || entry->is_metadata_encrypted)); +} + /* * Functions to set archive_entry properties. */ @@ -1216,6 +1239,22 @@ archive_entry_update_uname_utf8(struct archive_entry *entry, const char *name) return (0); } +void +archive_entry_set_is_data_encrypted(struct archive_entry *entry, char encrypted) +{ + if (entry) { + entry->is_data_encrypted = encrypted; + } +} + +void +archive_entry_set_is_metadata_encrypted(struct archive_entry *entry, char encrypted) +{ + if (entry) { + entry->is_metadata_encrypted = encrypted; + } +} + int _archive_entry_copy_uname_l(struct archive_entry *entry, const char *name, size_t len, struct archive_string_conv *sc) diff --git a/libarchive/archive_entry.h b/libarchive/archive_entry.h index a9050652e..ebd85d979 100644 --- a/libarchive/archive_entry.h +++ b/libarchive/archive_entry.h @@ -235,6 +235,9 @@ __LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *); __LA_DECL __LA_INT64_T archive_entry_uid(struct archive_entry *); __LA_DECL const char *archive_entry_uname(struct archive_entry *); __LA_DECL const wchar_t *archive_entry_uname_w(struct archive_entry *); +__LA_DECL int archive_entry_is_data_encrypted(struct archive_entry *); +__LA_DECL int archive_entry_is_metadata_encrypted(struct archive_entry *); +__LA_DECL int archive_entry_is_encrypted(struct archive_entry *); /* * Set fields in an archive_entry. @@ -306,6 +309,8 @@ __LA_DECL void archive_entry_set_uname(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_uname(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *); __LA_DECL int archive_entry_update_uname_utf8(struct archive_entry *, const char *); +__LA_DECL void archive_entry_set_is_data_encrypted(struct archive_entry *, char encrypted); +__LA_DECL void archive_entry_set_is_metadata_encrypted(struct archive_entry *, char encrypted); /* * Routines to bulk copy fields to/from a platform-native "struct * stat." Libarchive used to just store a struct stat inside of each diff --git a/libarchive/archive_entry_private.h b/libarchive/archive_entry_private.h index e3547c3e3..74b50da6b 100644 --- a/libarchive/archive_entry_private.h +++ b/libarchive/archive_entry_private.h @@ -154,6 +154,9 @@ struct archive_entry { /* Not used within libarchive; useful for some clients. */ struct archive_mstring ae_sourcepath; /* Path this entry is sourced from. */ + char is_data_encrypted; + char is_metadata_encrypted; + void *mac_metadata; size_t mac_metadata_size; diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c index 048c316c5..77293837d 100644 --- a/libarchive/archive_read.c +++ b/libarchive/archive_read.c @@ -746,6 +746,31 @@ archive_read_header_position(struct archive *_a) return (a->header_position); } +/* Returns "true" (non-zero) if the archive contains encrypted entries; otherwise 0 is returned. */ +int +archive_read_has_encrypted_entries(struct archive *_a) +{ + struct archive_read *a = (struct archive_read *)_a; + if (a && a->format && a->format->has_encrypted_entries) { + return (a->format->has_encrypted_entries)(a); + } + return 0; +} + +/* + * Returns a bitmask of capabilities that are supported by the archive format reader. + * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned. + */ +int +archive_read_format_capabilities(struct archive *_a) +{ + struct archive_read *a = (struct archive_read *)_a; + if (a && a->format && a->format->format_capabilties) { + return (a->format->format_capabilties)(a); + } + return ARCHIVE_READ_FORMAT_CAPS_NONE; +} + /* * Read data from an archive entry, using a read(2)-style interface. * This is a convenience routine that just calls @@ -1094,7 +1119,9 @@ __archive_read_register_format(struct archive_read *a, int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *), int (*read_data_skip)(struct archive_read *), int64_t (*seek_data)(struct archive_read *, int64_t, int), - int (*cleanup)(struct archive_read *)) + int (*cleanup)(struct archive_read *), + int (*format_capabilities)(struct archive_read *), + int (*has_encrypted_entries)(struct archive_read *)) { int i, number_slots; @@ -1117,6 +1144,8 @@ __archive_read_register_format(struct archive_read *a, a->formats[i].cleanup = cleanup; a->formats[i].data = format_data; a->formats[i].name = name; + a->formats[i].format_capabilties = format_capabilities; + a->formats[i].has_encrypted_entries = has_encrypted_entries; return (ARCHIVE_OK); } } diff --git a/libarchive/archive_read_private.h b/libarchive/archive_read_private.h index 8a6c859a8..0dc0c776c 100644 --- a/libarchive/archive_read_private.h +++ b/libarchive/archive_read_private.h @@ -207,6 +207,8 @@ struct archive_read { int (*read_data_skip)(struct archive_read *); int64_t (*seek_data)(struct archive_read *, int64_t, int); int (*cleanup)(struct archive_read *); + int (*format_capabilties)(struct archive_read *); + int (*has_encrypted_entries)(struct archive_read *); } formats[16]; struct archive_format_descriptor *format; /* Active format. */ @@ -226,7 +228,9 @@ int __archive_read_register_format(struct archive_read *a, int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *), int (*read_data_skip)(struct archive_read *), int64_t (*seek_data)(struct archive_read *, int64_t, int), - int (*cleanup)(struct archive_read *)); + int (*cleanup)(struct archive_read *), + int (*format_capabilities)(struct archive_read *), + int (*has_encrypted_entries)(struct archive_read *)); int __archive_read_get_bidder(struct archive_read *a, struct archive_read_filter_bidder **bidder); diff --git a/libarchive/archive_read_support_format_7zip.c b/libarchive/archive_read_support_format_7zip.c index 194b8d51c..c8284792c 100644 --- a/libarchive/archive_read_support_format_7zip.c +++ b/libarchive/archive_read_support_format_7zip.c @@ -69,7 +69,11 @@ __FBSDID("$FreeBSD$"); #define _7Z_BZ2 0x040202 #define _7Z_PPMD 0x030401 #define _7Z_DELTA 0x03 -#define _7Z_CRYPTO 0x06F10701 +#define _7Z_CRYPTO_MAIN_ZIP 0x06F10101 /* Main Zip crypto algo */ +#define _7Z_CRYPTO_RAR_29 0x06F10303 /* Rar29 AES-128 + (modified SHA-1) */ +#define _7Z_CRYPTO_AES_256_SHA_256 0x06F10701 /* AES-256 + SHA-256 */ + + #define _7Z_X86 0x03030103 #define _7Z_X86_BCJ2 0x0303011B #define _7Z_POWERPC 0x03030205 @@ -322,8 +326,13 @@ struct _7zip { struct archive_string_conv *sconv; char format_name[64]; + + /* Custom value that is non-zero if this archive contains encrypted entries. */ + char has_encrypted_entries; }; +static int archive_read_format_7zip_has_encrypted_entries(struct archive_read *); +static int archive_read_support_format_7zip_capabilities(struct archive_read *a); static int archive_read_format_7zip_bid(struct archive_read *, int); static int archive_read_format_7zip_cleanup(struct archive_read *); static int archive_read_format_7zip_read_data(struct archive_read *, @@ -410,13 +419,36 @@ archive_read_support_format_7zip(struct archive *_a) archive_read_format_7zip_read_data, archive_read_format_7zip_read_data_skip, NULL, - archive_read_format_7zip_cleanup); + archive_read_format_7zip_cleanup, + archive_read_support_format_7zip_capabilities, + archive_read_format_7zip_has_encrypted_entries); if (r != ARCHIVE_OK) free(zip); return (ARCHIVE_OK); } +static int +archive_read_support_format_7zip_capabilities(struct archive_read * a) +{ + (void)a; /* UNUSED */ + return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | + ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA); +} + + +static int +archive_read_format_7zip_has_encrypted_entries(struct archive_read *_a) +{ + if (_a && _a->format) { + struct _7zip * zip = (struct _7zip *)_a->format->data; + if (zip && zip->has_encrypted_entries) { + return 1; + } + } + return 0; +} + static int archive_read_format_7zip_bid(struct archive_read *a, int best_bid) { @@ -568,6 +600,8 @@ archive_read_format_7zip_read_header(struct archive_read *a, struct _7zip *zip = (struct _7zip *)a->format->data; struct _7zip_entry *zip_entry; int r, ret = ARCHIVE_OK; + struct _7z_folder *folder = 0; + uint64_t fidx = 0; a->archive.archive_format = ARCHIVE_FORMAT_7ZIP; if (a->archive.archive_format_name == NULL) @@ -603,6 +637,25 @@ archive_read_format_7zip_read_header(struct archive_read *a, if (zip->sconv == NULL) return (ARCHIVE_FATAL); } + + /* Figure out if the entry is encrypted by looking at the folder + that is associated to the current 7zip entry. If the folder + has a coder with a _7Z_CRYPTO codec then the folder is encrypted. + Hence the entry must also be encrypted. */ + if (zip_entry && zip_entry->folderIndex < zip->si.ci.numFolders) { + folder = &(zip->si.ci.folders[zip_entry->folderIndex]); + for (fidx=0; folder && fidxnumCoders; fidx++) { + switch(folder->coders[fidx].codec) { + case _7Z_CRYPTO_MAIN_ZIP: + case _7Z_CRYPTO_RAR_29: + case _7Z_CRYPTO_AES_256_SHA_256: { + archive_entry_set_is_data_encrypted(entry, 1); + zip->has_encrypted_entries = 1; + break; + } + } + } + } if (archive_entry_copy_pathname_l(entry, (const char *)zip_entry->utf16name, @@ -1203,6 +1256,17 @@ init_decompression(struct archive_read *a, struct _7zip *zip, archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Unexpected codec ID: %lX", zip->codec); return (ARCHIVE_FAILED); + case _7Z_CRYPTO_MAIN_ZIP: + case _7Z_CRYPTO_RAR_29: + case _7Z_CRYPTO_AES_256_SHA_256: + if (a->entry) { + archive_entry_set_is_metadata_encrypted(a->entry, 1); + archive_entry_set_is_data_encrypted(a->entry, 1); + zip->has_encrypted_entries = 1; + } + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Crypto codec not supported yet (ID: 0x%lX)", zip->codec); + return (ARCHIVE_FAILED); default: archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Unknown codec ID: %lX", zip->codec); @@ -2755,6 +2819,7 @@ slurp_central_directory(struct archive_read *a, struct _7zip *zip, zip->header_crc32 = 0; zip->header_is_encoded = 0; zip->header_is_being_read = 1; + zip->has_encrypted_entries = 0; check_header_crc = 1; if ((p = header_bytes(a, 1)) == NULL) { @@ -3235,15 +3300,28 @@ setup_decode_folder(struct archive_read *a, struct _7z_folder *folder, * Check coder types. */ for (i = 0; i < folder->numCoders; i++) { - if (folder->coders[i].codec == _7Z_CRYPTO) { - archive_set_error(&(a->archive), - ARCHIVE_ERRNO_MISC, - "The %s is encrypted, " - "but currently not supported", cname); - return (ARCHIVE_FATAL); + switch(folder->coders[i].codec) { + case _7Z_CRYPTO_MAIN_ZIP: + case _7Z_CRYPTO_RAR_29: + case _7Z_CRYPTO_AES_256_SHA_256: { + /* For entry that is associated with this folder, mark + it as encrypted (data+metadata). */ + zip->has_encrypted_entries = 1; + if (a->entry) { + archive_entry_set_is_data_encrypted(a->entry, 1); + archive_entry_set_is_metadata_encrypted(a->entry, 1); + } + archive_set_error(&(a->archive), + ARCHIVE_ERRNO_MISC, + "The %s is encrypted, " + "but currently not supported", cname); + return (ARCHIVE_FATAL); + } + case _7Z_X86_BCJ2: { + found_bcj2++; + break; + } } - if (folder->coders[i].codec == _7Z_X86_BCJ2) - found_bcj2++; } if ((folder->numCoders > 2 && !found_bcj2) || found_bcj2 > 1) { archive_set_error(&(a->archive), diff --git a/libarchive/archive_read_support_format_ar.c b/libarchive/archive_read_support_format_ar.c index 40be18c0c..82756c976 100644 --- a/libarchive/archive_read_support_format_ar.c +++ b/libarchive/archive_read_support_format_ar.c @@ -122,7 +122,9 @@ archive_read_support_format_ar(struct archive *_a) archive_read_format_ar_read_data, archive_read_format_ar_skip, NULL, - archive_read_format_ar_cleanup); + archive_read_format_ar_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) { free(ar); diff --git a/libarchive/archive_read_support_format_cab.c b/libarchive/archive_read_support_format_cab.c index 3c9f94ca6..fc70684af 100644 --- a/libarchive/archive_read_support_format_cab.c +++ b/libarchive/archive_read_support_format_cab.c @@ -383,7 +383,9 @@ archive_read_support_format_cab(struct archive *_a) archive_read_format_cab_read_data, archive_read_format_cab_read_data_skip, NULL, - archive_read_format_cab_cleanup); + archive_read_format_cab_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) free(cab); diff --git a/libarchive/archive_read_support_format_cpio.c b/libarchive/archive_read_support_format_cpio.c index 819f4a4f5..0b6968980 100644 --- a/libarchive/archive_read_support_format_cpio.c +++ b/libarchive/archive_read_support_format_cpio.c @@ -243,7 +243,9 @@ archive_read_support_format_cpio(struct archive *_a) archive_read_format_cpio_read_data, archive_read_format_cpio_skip, NULL, - archive_read_format_cpio_cleanup); + archive_read_format_cpio_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) free(cpio); diff --git a/libarchive/archive_read_support_format_empty.c b/libarchive/archive_read_support_format_empty.c index 366073820..c641eb9b1 100644 --- a/libarchive/archive_read_support_format_empty.c +++ b/libarchive/archive_read_support_format_empty.c @@ -54,6 +54,8 @@ archive_read_support_format_empty(struct archive *_a) archive_read_format_empty_read_data, NULL, NULL, + NULL, + NULL, NULL); return (r); diff --git a/libarchive/archive_read_support_format_iso9660.c b/libarchive/archive_read_support_format_iso9660.c index 914bc71df..86d07fecb 100644 --- a/libarchive/archive_read_support_format_iso9660.c +++ b/libarchive/archive_read_support_format_iso9660.c @@ -478,7 +478,9 @@ archive_read_support_format_iso9660(struct archive *_a) archive_read_format_iso9660_read_data, archive_read_format_iso9660_read_data_skip, NULL, - archive_read_format_iso9660_cleanup); + archive_read_format_iso9660_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) { free(iso9660); diff --git a/libarchive/archive_read_support_format_lha.c b/libarchive/archive_read_support_format_lha.c index f702949fb..b88731afa 100644 --- a/libarchive/archive_read_support_format_lha.c +++ b/libarchive/archive_read_support_format_lha.c @@ -320,7 +320,9 @@ archive_read_support_format_lha(struct archive *_a) archive_read_format_lha_read_data, archive_read_format_lha_read_data_skip, NULL, - archive_read_format_lha_cleanup); + archive_read_format_lha_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) free(lha); diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c index c4e7021a8..e10ef4f96 100644 --- a/libarchive/archive_read_support_format_mtree.c +++ b/libarchive/archive_read_support_format_mtree.c @@ -205,7 +205,7 @@ archive_read_support_format_mtree(struct archive *_a) mtree->fd = -1; r = __archive_read_register_format(a, mtree, "mtree", - mtree_bid, NULL, read_header, read_data, skip, NULL, cleanup); + mtree_bid, NULL, read_header, read_data, skip, NULL, cleanup, NULL, NULL); if (r != ARCHIVE_OK) free(mtree); diff --git a/libarchive/archive_read_support_format_rar.c b/libarchive/archive_read_support_format_rar.c index 99c57a0fc..88195a94f 100644 --- a/libarchive/archive_read_support_format_rar.c +++ b/libarchive/archive_read_support_format_rar.c @@ -304,8 +304,15 @@ struct rar ssize_t avail_in; const unsigned char *next_in; } br; + + /* + * Custom field to denote that this archive contains encrypted entries + */ + char has_encrypted_entries; }; +static int archive_read_support_format_rar_capabilities(struct archive_read *); +static int archive_read_format_rar_has_encrypted_entries(struct archive_read *); static int archive_read_format_rar_bid(struct archive_read *, int); static int archive_read_format_rar_options(struct archive_read *, const char *, const char *); @@ -655,13 +662,36 @@ archive_read_support_format_rar(struct archive *_a) archive_read_format_rar_read_data, archive_read_format_rar_read_data_skip, archive_read_format_rar_seek_data, - archive_read_format_rar_cleanup); + archive_read_format_rar_cleanup, + archive_read_support_format_rar_capabilities, + archive_read_format_rar_has_encrypted_entries); if (r != ARCHIVE_OK) free(rar); return (r); } +static int +archive_read_support_format_rar_capabilities(struct archive_read * a) +{ + (void)a; /* UNUSED */ + return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA + | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA); +} + +static int +archive_read_format_rar_has_encrypted_entries(struct archive_read *_a) +{ + if (_a && _a->format) { + struct rar * rar = (struct rar *)_a->format->data; + if (rar && rar->has_encrypted_entries) { + return 1; + } + } + return 0; +} + + static int archive_read_format_rar_bid(struct archive_read *a, int best_bid) { @@ -857,9 +887,14 @@ archive_read_format_rar_read_header(struct archive_read *a, sizeof(rar->reserved2)); } + /* Main header is password encrytped, so we cannot read any + file names or any other info about files from the header. */ if (rar->main_flags & MHD_PASSWORD) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + archive_entry_set_is_metadata_encrypted(entry, 1); + archive_entry_set_is_data_encrypted(entry, 1); + rar->has_encrypted_entries = 1; + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "RAR encryption support unavailable."); return (ARCHIVE_FATAL); } @@ -1290,9 +1325,14 @@ read_header(struct archive_read *a, struct archive_entry *entry, if (rar->file_flags & FHD_PASSWORD) { + archive_entry_set_is_data_encrypted(entry, 1); + rar->has_encrypted_entries = 1; archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "RAR encryption support unavailable."); - return (ARCHIVE_FATAL); + /* Since it is only the data part itself that is encrypted we can at least + extract information about the currently processed entry and don't need + to return ARCHIVE_FATAL here. */ + /*return (ARCHIVE_FATAL);*/ } if (rar->file_flags & FHD_LARGE) diff --git a/libarchive/archive_read_support_format_raw.c b/libarchive/archive_read_support_format_raw.c index 843497878..efa2c6a33 100644 --- a/libarchive/archive_read_support_format_raw.c +++ b/libarchive/archive_read_support_format_raw.c @@ -78,7 +78,9 @@ archive_read_support_format_raw(struct archive *_a) archive_read_format_raw_read_data, archive_read_format_raw_read_data_skip, NULL, - archive_read_format_raw_cleanup); + archive_read_format_raw_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) free(info); return (r); diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c index 95960a2c1..603ea3f97 100644 --- a/libarchive/archive_read_support_format_tar.c +++ b/libarchive/archive_read_support_format_tar.c @@ -254,7 +254,9 @@ archive_read_support_format_tar(struct archive *_a) archive_read_format_tar_read_data, archive_read_format_tar_skip, NULL, - archive_read_format_tar_cleanup); + archive_read_format_tar_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) free(tar); diff --git a/libarchive/archive_read_support_format_xar.c b/libarchive/archive_read_support_format_xar.c index 6a9e1923b..b0f535221 100644 --- a/libarchive/archive_read_support_format_xar.c +++ b/libarchive/archive_read_support_format_xar.c @@ -468,7 +468,9 @@ archive_read_support_format_xar(struct archive *_a) xar_read_data, xar_read_data_skip, NULL, - xar_cleanup); + xar_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) free(xar); return (r); diff --git a/libarchive/archive_read_support_format_zip.c b/libarchive/archive_read_support_format_zip.c index 84e545e0f..6a77dd7e7 100644 --- a/libarchive/archive_read_support_format_zip.c +++ b/libarchive/archive_read_support_format_zip.c @@ -74,9 +74,11 @@ struct zip { int64_t end_of_central_directory_offset; int64_t central_directory_offset; size_t central_directory_size; - size_t central_directory_entries; + size_t central_directory_entries_total; + size_t central_directory_entries_on_this_disk; char have_central_directory; int64_t offset; + char has_encrypted_entries; /* List of entries (seekable Zip only) */ size_t entries_remaining; @@ -120,10 +122,16 @@ struct zip { }; #define ZIP_LENGTH_AT_END 8 -#define ZIP_ENCRYPTED (1<<0) -#define ZIP_STRONG_ENCRYPTED (1<<6) -#define ZIP_UTF8_NAME (1<<11) - +#define ZIP_ENCRYPTED (1<<0) +#define ZIP_STRONG_ENCRYPTED (1<<6) +/* See "7.2 Single Password Symmetric Encryption Method" + in http://www.pkware.com/documents/casestudies/APPNOTE.TXT */ +#define ZIP_CENTRAL_DIRECTORY_ENCRYPTED (1<<13) +#define ZIP_UTF8_NAME (1<<11) + +static int archive_read_format_zip_has_encrypted_entries(struct archive_read *); +static int archive_read_support_format_zip_capabilities_seekable(struct archive_read *a); +static int archive_read_support_format_zip_capabilities_streamable(struct archive_read *a); static int archive_read_format_zip_streamable_bid(struct archive_read *, int); static int archive_read_format_zip_seekable_bid(struct archive_read *, @@ -182,7 +190,9 @@ archive_read_support_format_zip_streamable(struct archive *_a) archive_read_format_zip_read_data, archive_read_format_zip_read_data_skip, NULL, - archive_read_format_zip_cleanup); + archive_read_format_zip_cleanup, + archive_read_support_format_zip_capabilities_streamable, + archive_read_format_zip_has_encrypted_entries); if (r != ARCHIVE_OK) free(zip); @@ -216,13 +226,42 @@ archive_read_support_format_zip_seekable(struct archive *_a) archive_read_format_zip_read_data, archive_read_format_zip_read_data_skip, NULL, - archive_read_format_zip_cleanup); + archive_read_format_zip_cleanup, + archive_read_support_format_zip_capabilities_seekable, + archive_read_format_zip_has_encrypted_entries); if (r != ARCHIVE_OK) free(zip); return (ARCHIVE_OK); } +static int +archive_read_support_format_zip_capabilities_seekable(struct archive_read * a) +{ + (void)a; /* UNUSED */ + return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA); +} + +static int +archive_read_support_format_zip_capabilities_streamable(struct archive_read * a) +{ + (void)a; /* UNUSED */ + return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA); +} + + +static int +archive_read_format_zip_has_encrypted_entries(struct archive_read *_a) +{ + if (_a && _a->format) { + struct zip * zip = (struct zip *)_a->format->data; + if (zip && zip->has_encrypted_entries) { + return 1; + } + } + return 0; +} + int archive_read_support_format_zip(struct archive *a) { @@ -307,18 +346,20 @@ archive_read_format_zip_seekable_bid(struct archive_read *a, int best_bid) if (!found) return 0; } - + /* Since we've already done the hard work of finding the end of central directory record, let's save the important information. */ - zip->central_directory_entries = archive_le16dec(p + 10); + zip->central_directory_entries_on_this_disk = archive_le16dec(p + 8); + zip->central_directory_entries_total = archive_le16dec(p + 10); zip->central_directory_size = archive_le32dec(p + 12); zip->central_directory_offset = archive_le32dec(p + 16); zip->end_of_central_directory_offset = filesize; - + /* Just one volume, so central dir must all be on this volume. */ - if (zip->central_directory_entries != archive_le16dec(p + 8)) + if (zip->central_directory_entries_total != zip->central_directory_entries_on_this_disk) { return 0; + } /* Central directory can't extend beyond end of this file. */ if (zip->central_directory_offset + (int64_t)zip->central_directory_size > filesize) @@ -435,9 +476,9 @@ slurp_central_directory(struct archive_read *a, struct zip *zip) __archive_rb_tree_init(&zip->tree, &rb_ops); __archive_rb_tree_init(&zip->tree_rsrc, &rb_rsrc_ops); - zip->zip_entries = calloc(zip->central_directory_entries, + zip->zip_entries = calloc(zip->central_directory_entries_total, sizeof(struct zip_entry)); - for (i = 0; i < zip->central_directory_entries; ++i) { + for (i = 0; i < zip->central_directory_entries_total; ++i) { struct zip_entry *zip_entry = &zip->zip_entries[i]; size_t filename_length, extra_length, comment_length; uint32_t external_attributes; @@ -455,6 +496,9 @@ slurp_central_directory(struct archive_read *a, struct zip *zip) zip_entry->system = p[5]; /* version_required = archive_le16dec(p + 6); */ zip_entry->flags = archive_le16dec(p + 8); + if (zip_entry->flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)){ + zip->has_encrypted_entries = 1; + } zip_entry->compression = (char)archive_le16dec(p + 10); zip_entry->mtime = zip_time(p + 12); zip_entry->crc32 = archive_le32dec(p + 16); @@ -468,7 +512,7 @@ slurp_central_directory(struct archive_read *a, struct zip *zip) external_attributes = archive_le32dec(p + 38); zip_entry->local_header_offset = archive_le32dec(p + 42) + correction; - + /* If we can't guess the mode, leave it zero here; when we read the local file header we might get more information. */ @@ -520,7 +564,6 @@ slurp_central_directory(struct archive_read *a, struct zip *zip) __archive_rb_tree_insert_node(&zip->tree, &zip_entry->node); } - /* We don't read the filename until we get to the local file header. Reading it here would speed up table-of-contents operations (removing the need to @@ -700,7 +743,7 @@ archive_read_format_zip_seekable_read_header(struct archive_read *a, if (zip->zip_entries == NULL) { r = slurp_central_directory(a, zip); - zip->entries_remaining = zip->central_directory_entries; + zip->entries_remaining = zip->central_directory_entries_total; if (r != ARCHIVE_OK) return r; /* Get first entry whose local header offset is lower than @@ -716,7 +759,7 @@ archive_read_format_zip_seekable_read_header(struct archive_read *a, if (zip->entries_remaining <= 0 || zip->entry == NULL) return ARCHIVE_EOF; --zip->entries_remaining; - + if (zip->entry->rsrcname.s) rsrc = (struct zip_entry *)__archive_rb_tree_find_node( &zip->tree_rsrc, zip->entry->rsrcname.s); @@ -989,6 +1032,16 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry, version = p[4]; zip_entry->system = p[5]; zip_entry->flags = archive_le16dec(p + 6); + if (zip_entry->flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) { + zip->has_encrypted_entries = 1; + archive_entry_set_is_data_encrypted(entry, 1); + if (zip_entry->flags & ZIP_CENTRAL_DIRECTORY_ENCRYPTED && + zip_entry->flags & ZIP_ENCRYPTED && + zip_entry->flags & ZIP_STRONG_ENCRYPTED) { + archive_entry_set_is_metadata_encrypted(entry, 1); + return ARCHIVE_FATAL; + } + } zip_entry->compression = (char)archive_le16dec(p + 8); zip_entry->mtime = zip_time(p + 10); local_crc32 = archive_le32dec(p + 14); @@ -1211,6 +1264,7 @@ archive_read_format_zip_read_data(struct archive_read *a, return (ARCHIVE_EOF); if (zip->entry->flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) { + zip->has_encrypted_entries = 1; archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Encrypted file is unsupported"); return (ARCHIVE_FAILED); @@ -1602,9 +1656,9 @@ archive_read_format_zip_cleanup(struct archive_read *a) if (zip->stream_valid) inflateEnd(&zip->stream); #endif - if (zip->zip_entries && zip->central_directory_entries) { + if (zip->zip_entries && zip->central_directory_entries_total) { unsigned i; - for (i = 0; i < zip->central_directory_entries; i++) + for (i = 0; i < zip->central_directory_entries_total; i++) archive_string_free(&(zip->zip_entries[i].rsrcname)); } free(zip->zip_entries); diff --git a/libarchive/test/CMakeLists.txt b/libarchive/test/CMakeLists.txt index dadea4c69..dc36cc897 100644 --- a/libarchive/test/CMakeLists.txt +++ b/libarchive/test/CMakeLists.txt @@ -87,6 +87,9 @@ IF(ENABLE_TEST) test_read_filter_program_signature.c test_read_filter_uudecode.c test_read_format_7zip.c + test_read_format_7zip_encryption_data.c + test_read_format_7zip_encryption_partially.c + test_read_format_7zip_encryption_header.c test_read_format_ar.c test_read_format_cab.c test_read_format_cab_filename.c @@ -127,6 +130,9 @@ IF(ENABLE_TEST) test_read_format_mtree.c test_read_format_pax_bz2.c test_read_format_rar.c + test_read_format_rar_encryption_data.c + test_read_format_rar_encryption_partially.c + test_read_format_rar_encryption_header.c test_read_format_raw.c test_read_format_tar.c test_read_format_tar_empty_pax.c @@ -141,6 +147,9 @@ IF(ENABLE_TEST) test_read_format_xar.c test_read_format_zip.c test_read_format_zip_comment_stored.c + test_read_format_zip_encryption_data.c + test_read_format_zip_encryption_partially.c + test_read_format_zip_encryption_header.c test_read_format_zip_filename.c test_read_format_zip_mac_metadata.c test_read_format_zip_sfx.c diff --git a/libarchive/test/test_read_format_7zip.c b/libarchive/test/test_read_format_7zip.c index 62657a821..eb79852c3 100644 --- a/libarchive/test/test_read_format_7zip.c +++ b/libarchive/test/test_read_format_7zip.c @@ -50,6 +50,8 @@ test_copy() assertEqualString("file1", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(60, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(60, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, " ", 4); @@ -122,6 +124,8 @@ test_empty_file() assertEqualString("empty", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(0, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(1, archive_file_count(a)); @@ -161,6 +165,8 @@ test_plain_header(const char *refname) assertEqualString("file1", archive_entry_pathname(ae)); assertEqualInt(1322058763, archive_entry_mtime(ae)); assertEqualInt(2844, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(sizeof(buff), archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "The libarchive distribution ", 28); @@ -202,6 +208,8 @@ test_extract_all_files(const char *refname) assertEqualString("dir1/file1", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(13, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(13, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "aaaaaaaaaaaa\n", 13); @@ -211,6 +219,8 @@ test_extract_all_files(const char *refname) assertEqualString("file2", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(26, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(26, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\n", 26); @@ -220,6 +230,8 @@ test_extract_all_files(const char *refname) assertEqualString("file3", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(39, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(39, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\n", 39); @@ -229,6 +241,8 @@ test_extract_all_files(const char *refname) assertEqualString("file4", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(52, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(52, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\ndddddddddddd\n", 52); @@ -238,6 +252,8 @@ test_extract_all_files(const char *refname) assertEqualInt((AE_IFDIR | 0755), archive_entry_mode(ae)); assertEqualString("dir1/", archive_entry_pathname(ae)); assertEqualInt(2764801, archive_entry_mtime(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(5, archive_file_count(a)); @@ -277,6 +293,8 @@ test_extract_last_file(const char *refname) assertEqualString("dir1/file1", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(13, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file2. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); @@ -284,6 +302,8 @@ test_extract_last_file(const char *refname) assertEqualString("file2", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(26, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file3. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); @@ -291,6 +311,8 @@ test_extract_last_file(const char *refname) assertEqualString("file3", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(39, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file4. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); @@ -298,6 +320,8 @@ test_extract_last_file(const char *refname) assertEqualString("file4", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(52, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(52, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\ndddddddddddd\n", 52); @@ -307,6 +331,8 @@ test_extract_last_file(const char *refname) assertEqualInt((AE_IFDIR | 0755), archive_entry_mode(ae)); assertEqualString("dir1/", archive_entry_pathname(ae)); assertEqualInt(2764801, archive_entry_mtime(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(5, archive_file_count(a)); @@ -347,6 +373,8 @@ test_extract_all_files2(const char *refname) assertEqualString("dir1/file1", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(13, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(13, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "aaaaaaaaaaaa\n", 13); @@ -356,6 +384,8 @@ test_extract_all_files2(const char *refname) assertEqualString("file2", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(26, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(26, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\n", 26); @@ -365,6 +395,8 @@ test_extract_all_files2(const char *refname) assertEqualString("file3", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(39, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(39, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\n", 39); @@ -374,6 +406,8 @@ test_extract_all_files2(const char *refname) assertEqualString("file4", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(52, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(52, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\ndddddddddddd\n", 52); @@ -384,6 +418,8 @@ test_extract_all_files2(const char *refname) assertEqualString("dir1/zfile1", archive_entry_pathname(ae)); assertEqualInt(5184001, archive_entry_mtime(ae)); assertEqualInt(13, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(13, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "aaaaaaaaaaaa\n", 13); @@ -393,6 +429,8 @@ test_extract_all_files2(const char *refname) assertEqualString("zfile2", archive_entry_pathname(ae)); assertEqualInt(5184001, archive_entry_mtime(ae)); assertEqualInt(26, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(26, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\n", 26); @@ -402,6 +440,8 @@ test_extract_all_files2(const char *refname) assertEqualString("zfile3", archive_entry_pathname(ae)); assertEqualInt(5184001, archive_entry_mtime(ae)); assertEqualInt(39, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(39, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\n", 39); @@ -411,6 +451,8 @@ test_extract_all_files2(const char *refname) assertEqualString("zfile4", archive_entry_pathname(ae)); assertEqualInt(5184001, archive_entry_mtime(ae)); assertEqualInt(52, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(52, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\ndddddddddddd\n", 52); @@ -420,6 +462,8 @@ test_extract_all_files2(const char *refname) assertEqualInt((AE_IFDIR | 0755), archive_entry_mode(ae)); assertEqualString("dir1/", archive_entry_pathname(ae)); assertEqualInt(2764801, archive_entry_mtime(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(9, archive_file_count(a)); @@ -460,6 +504,8 @@ test_delta_lzma(const char *refname) assertEqualString("file1", archive_entry_pathname(ae)); assertEqualInt(172802, archive_entry_mtime(ae)); assertEqualInt(27627, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); remaining = (size_t)archive_entry_size(ae); while (remaining) { if (remaining < sizeof(buff)) @@ -514,6 +560,8 @@ test_bcj(const char *refname) assertEqualString("x86exe", archive_entry_pathname(ae)); assertEqualInt(172802, archive_entry_mtime(ae)); assertEqualInt(27328, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); remaining = (size_t)archive_entry_size(ae); while (remaining) { if (remaining < sizeof(buff)) @@ -569,6 +617,8 @@ test_ppmd() assertEqualString("ppmd_test.txt", archive_entry_pathname(ae)); assertEqualInt(1322464589, archive_entry_mtime(ae)); assertEqualInt(102400, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); remaining = (size_t)archive_entry_size(ae); while (remaining) { if (remaining < sizeof(buff)) @@ -619,6 +669,8 @@ test_symname() assertEqualString("file1", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(32, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(32, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "hellohellohello\nhellohellohello\n", 32); @@ -628,6 +680,8 @@ test_symname() assertEqualString("symlinkfile", archive_entry_pathname(ae)); assertEqualString("file1", archive_entry_symlink(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(2, archive_file_count(a)); diff --git a/libarchive/test/test_read_format_7zip_encryption.7z.uu b/libarchive/test/test_read_format_7zip_encryption.7z.uu new file mode 100644 index 000000000..5122679f6 --- /dev/null +++ b/libarchive/test/test_read_format_7zip_encryption.7z.uu @@ -0,0 +1,7 @@ +begin 664 test_read_format_7zip_encryption.7z +M-WJ\KR<<``."K^J($`````````!A`````````%C_;&JY#8C0K"UKHUJ[Y37? +MT4'9`00&``$)$``'"P$``B0&\0`!T````%`H!``"&-JAYL,X! +*%08!`""`M($````` +` +end diff --git a/libarchive/test/test_read_format_7zip_encryption_data.c b/libarchive/test/test_read_format_7zip_encryption_data.c new file mode 100644 index 000000000..4820da7b1 --- /dev/null +++ b/libarchive/test/test_read_format_7zip_encryption_data.c @@ -0,0 +1,68 @@ +/*- + * Copyright (c) 2013 Konrad Kleine + * 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"); + +DEFINE_TEST(test_read_format_7zip_encryption_data) +{ + /* This file is password protected (encrypted) with AES-256. The headers + are NOT encrypted. Password is "12345678". */ + const char *refname = "test_read_format_7zip_encryption.7z"; + struct archive_entry *ae; + struct archive *a; + char buff[128]; + + extract_reference_file(refname); + 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)); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_open_filename(a, refname, 10240)); + + /* Verify encrypted file "bar.txt". */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae)); + assertEqualString("bar.txt", archive_entry_pathname(ae)); + assertEqualInt(1379073980, archive_entry_mtime(ae)); + assertEqualInt(4, archive_entry_size(ae)); + assertEqualInt(1, archive_entry_is_data_encrypted(ae)); + assertEqualInt(0, archive_entry_is_metadata_encrypted(ae)); + assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a)); + assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff))); + + assertEqualInt(1, archive_file_count(a)); + + /* End of archive. */ + assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + + /* Verify archive format. */ + assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0)); + assertEqualIntA(a, ARCHIVE_FORMAT_7ZIP, archive_format(a)); + + /* Close the archive. */ + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} + diff --git a/libarchive/test/test_read_format_7zip_encryption_header.7z.uu b/libarchive/test/test_read_format_7zip_encryption_header.7z.uu new file mode 100644 index 000000000..cdabd247e --- /dev/null +++ b/libarchive/test/test_read_format_7zip_encryption_header.7z.uu @@ -0,0 +1,8 @@ +begin 664 test_read_format_7zip_encryption_header.7z +M-WJ\KR<<``-1(7)]@``````````F`````````!I:QVF.6KJ?=[:U9:-!,8A0 +MB6O0&LG!?DD:R_'07!.!NV;/LY)*FIFWXUI[)=TPG&";5C%*%S+LERGW+.D%XK*'>5.FQ>74JN]"%`5%TTQ[@L^# +MZVV`LJT"61@``($S!ZXQF+DAMZ?L<`,6_>V19<3;V2;&..`F/OY`DLGI +MB?L"X_1-'%<>!(3'6&[GTF&K$I`20KWW0T2OU80/'3WLJ@2\\?YH6A7J\T[" +M5JH6Y6_..SN-L'T>$^";VM@^(Y(^]N\E588GW68QK>M[C@$[AM@/<+RH]Q!& +J"GI1?FZ````7!A@!"8"$``<+`0`!(P,!`05=`!````R`N@H!F[7,7``` +` +end diff --git a/libarchive/test/test_read_format_7zip_encryption_partially.c b/libarchive/test/test_read_format_7zip_encryption_partially.c new file mode 100644 index 000000000..31252fc75 --- /dev/null +++ b/libarchive/test/test_read_format_7zip_encryption_partially.c @@ -0,0 +1,79 @@ +/*- + * Copyright (c) 2013 Konrad Kleine + * 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"); + +DEFINE_TEST(test_read_format_7zip_encryption_partially) +{ + /* This file is password protected (encrypted) with AES-256. The headers + are NOT encrypted. Password is "12345678". It contains one encrypted + and one unencrypted file. */ + const char *refname = "test_read_format_7zip_encryption_partially.7z"; + struct archive_entry *ae; + struct archive *a; + char buff[128]; + + extract_reference_file(refname); + 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)); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_open_filename(a, refname, 10240)); + + /* Verify regular unencrypted file1. */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae)); + assertEqualString("bar_unencrypted.txt", archive_entry_pathname(ae)); + assertEqualInt(1379079541, archive_entry_mtime(ae)); + assertEqualInt(4, archive_entry_size(ae)); + assertEqualInt(0, archive_entry_is_data_encrypted(ae)); + assertEqualInt(0, archive_entry_is_metadata_encrypted(ae)); + assertEqualIntA(a, 0, archive_read_has_encrypted_entries(a)); + assertEqualInt(4, archive_read_data(a, buff, sizeof(buff))); + + /* Verify regular encrypted file2. */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae)); + assertEqualString("bar_encrypted.txt", archive_entry_pathname(ae)); + assertEqualInt(1379079565, archive_entry_mtime(ae)); + assertEqualInt(4, archive_entry_size(ae)); + assertEqualInt(1, archive_entry_is_data_encrypted(ae)); + assertEqualInt(0, archive_entry_is_metadata_encrypted(ae)); + assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a)); + assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff))); + + assertEqualInt(2, archive_file_count(a)); + + /* End of archive. */ + assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae)); + + /* Verify archive format. */ + assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0)); + assertEqualIntA(a, ARCHIVE_FORMAT_7ZIP, archive_format(a)); + + /* Close the archive. */ + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} diff --git a/libarchive/test/test_read_format_ar.c b/libarchive/test/test_read_format_ar.c index e70d1ae55..55e8b318f 100644 --- a/libarchive/test/test_read_format_ar.c +++ b/libarchive/test/test_read_format_ar.c @@ -49,6 +49,8 @@ DEFINE_TEST(test_read_format_ar) assertEqualInt(0, archive_entry_uid(ae)); assertEqualInt(0, archive_entry_gid(ae)); assertEqualInt(0, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* First Entry */ assertA(0 == archive_read_next_header(a, &ae)); @@ -59,6 +61,8 @@ DEFINE_TEST(test_read_format_ar) assert(8 == archive_entry_size(ae)); assertA(8 == archive_read_data(a, buff, 10)); assertEqualMem(buff, "55667788", 8); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Second Entry */ assertA(0 == archive_read_next_header(a, &ae)); @@ -69,6 +73,8 @@ DEFINE_TEST(test_read_format_ar) assert(4 == archive_entry_size(ae)); assertA(4 == archive_read_data(a, buff, 10)); assertEqualMem(buff, "3333", 4); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Third Entry */ assertA(0 == archive_read_next_header(a, &ae)); diff --git a/libarchive/test/test_read_format_cab.c b/libarchive/test/test_read_format_cab.c index e09d46d23..8b77d898e 100644 --- a/libarchive/test/test_read_format_cab.c +++ b/libarchive/test/test_read_format_cab.c @@ -204,6 +204,8 @@ verify(const char *refname, enum comp_type comp) assertEqualInt(0, archive_entry_uid(ae)); assertEqualInt(0, archive_entry_gid(ae)); assertEqualInt(0, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); if (comp != STORE) { /* Verify regular zero. @@ -215,6 +217,8 @@ verify(const char *refname, enum comp_type comp) assertEqualString("zero", archive_entry_pathname(ae)); assertEqualInt(0, archive_entry_uid(ae)); assertEqualInt(0, archive_entry_gid(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(33000, archive_entry_size(ae)); for (s = 0; s + sizeof(buff) < 33000; s+= sizeof(buff)) { ssize_t rsize = archive_read_data(a, buff, sizeof(buff)); @@ -236,6 +240,8 @@ verify(const char *refname, enum comp_type comp) assertEqualString("dir1/file1", archive_entry_pathname(ae)); assertEqualInt(0, archive_entry_uid(ae)); assertEqualInt(0, archive_entry_gid(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(file1_size, archive_entry_size(ae)); assertEqualInt(file1_size, archive_read_data(a, buff, file1_size)); assertEqualMem(buff, file1, file1_size); @@ -246,6 +252,8 @@ verify(const char *refname, enum comp_type comp) assertEqualString("dir2/file2", archive_entry_pathname(ae)); assertEqualInt(0, archive_entry_uid(ae)); assertEqualInt(0, archive_entry_gid(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(file2_size, archive_entry_size(ae)); assertEqualInt(file2_size, archive_read_data(a, buff, file2_size)); assertEqualMem(buff, file2, file2_size); @@ -295,11 +303,17 @@ verify2(const char *refname, enum comp_type comp) /* Verify regular empty. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); if (comp != STORE) { assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); } /* Verify regular file1. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file2. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); @@ -349,14 +363,22 @@ verify3(const char *refname, enum comp_type comp) /* Verify regular empty. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); if (comp != STORE) { assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); } /* Verify regular file1. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file2. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); diff --git a/libarchive/test/test_read_format_cab_filename.c b/libarchive/test/test_read_format_cab_filename.c index f148590ff..885f750a0 100644 --- a/libarchive/test/test_read_format_cab_filename.c +++ b/libarchive/test/test_read_format_cab_filename.c @@ -58,6 +58,8 @@ test_read_format_cab_filename_CP932_eucJP(const char *refname) "\xc9\xbd\xa4\xc0\xa4\xe8\x2f\xb4\xc1\xbb\xfa\x2e\x74\x78\x74", archive_entry_pathname(ae)); assertEqualInt(5, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); @@ -65,6 +67,8 @@ test_read_format_cab_filename_CP932_eucJP(const char *refname) "\xc9\xbd\xa4\xc0\xa4\xe8\x2f\xb0\xec\xcd\xf7\xc9\xbd\x2e\x74\x78\x74", archive_entry_pathname(ae)); assertEqualInt(5, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ @@ -122,6 +126,8 @@ test_read_format_cab_filename_CP932_UTF8(const char *refname) archive_entry_pathname(ae)); assertEqualInt(5, archive_entry_size(ae)); #endif + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); @@ -139,6 +145,8 @@ test_read_format_cab_filename_CP932_UTF8(const char *refname) archive_entry_pathname(ae)); #endif assertEqualInt(5, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ diff --git a/libarchive/test/test_read_format_cpio_afio.c b/libarchive/test/test_read_format_cpio_afio.c index db6003f95..f5c4a3d27 100644 --- a/libarchive/test/test_read_format_cpio_afio.c +++ b/libarchive/test/test_read_format_cpio_afio.c @@ -98,6 +98,8 @@ DEFINE_TEST(test_read_format_cpio_afio) */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualInt(17, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(archive_filter_code(a, 0) == ARCHIVE_FILTER_NONE); assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_POSIX); /* @@ -107,6 +109,8 @@ DEFINE_TEST(test_read_format_cpio_afio) assertEqualInt(17, archive_entry_size(ae)); if (uid_size() > 4) assertEqualInt(65536, archive_entry_uid(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(archive_filter_code(a, 0) == ARCHIVE_FILTER_NONE); assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_AFIO_LARGE); assertEqualInt(ARCHIVE_OK, archive_read_close(a)); diff --git a/libarchive/test/test_read_format_cpio_bin.c b/libarchive/test/test_read_format_cpio_bin.c index e65cb9b38..26980d7a5 100644 --- a/libarchive/test/test_read_format_cpio_bin.c +++ b/libarchive/test/test_read_format_cpio_bin.c @@ -52,6 +52,8 @@ DEFINE_TEST(test_read_format_cpio_bin) assertEqualIntA(a, 0, archive_read_open_memory(a, archive, sizeof(archive))); assertEqualIntA(a, 0, archive_read_next_header(a, &ae)); assertEqualInt(1, archive_file_count(a)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0)); assertEqualIntA(a, ARCHIVE_FORMAT_CPIO_BIN_LE, archive_format(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); diff --git a/libarchive/test/test_read_format_cpio_bin_Z.c b/libarchive/test/test_read_format_cpio_bin_Z.c index 8aca71f24..d6c515065 100644 --- a/libarchive/test/test_read_format_cpio_bin_Z.c +++ b/libarchive/test/test_read_format_cpio_bin_Z.c @@ -51,6 +51,8 @@ DEFINE_TEST(test_read_format_cpio_bin_Z) failure("archive_format_name(a)=\"%s\"", archive_format_name(a)); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_cpio_bin_be.c b/libarchive/test/test_read_format_cpio_bin_be.c index dfd664c9a..c114b5095 100644 --- a/libarchive/test/test_read_format_cpio_bin_be.c +++ b/libarchive/test/test_read_format_cpio_bin_be.c @@ -44,6 +44,8 @@ DEFINE_TEST(test_read_format_cpio_bin_be) assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644); assertEqualInt(archive_entry_uid(ae), 1000); assertEqualInt(archive_entry_gid(ae), 0); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_NONE); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_BE); diff --git a/libarchive/test/test_read_format_cpio_bin_bz2.c b/libarchive/test/test_read_format_cpio_bin_bz2.c index 8afbbcd1e..58637b3a1 100644 --- a/libarchive/test/test_read_format_cpio_bin_bz2.c +++ b/libarchive/test/test_read_format_cpio_bin_bz2.c @@ -49,6 +49,8 @@ DEFINE_TEST(test_read_format_cpio_bin_bz2) assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, archive, sizeof(archive))); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assert(archive_filter_code(a, 0) == ARCHIVE_FILTER_BZIP2); assert(archive_format(a) == ARCHIVE_FORMAT_CPIO_BIN_LE); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); diff --git a/libarchive/test/test_read_format_cpio_bin_gz.c b/libarchive/test/test_read_format_cpio_bin_gz.c index 98f53578e..5aa8beb54 100644 --- a/libarchive/test/test_read_format_cpio_bin_gz.c +++ b/libarchive/test/test_read_format_cpio_bin_gz.c @@ -53,6 +53,8 @@ DEFINE_TEST(test_read_format_cpio_bin_gz) assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_GZIP); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE); assertEqualInt(ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); diff --git a/libarchive/test/test_read_format_cpio_bin_lzip.c b/libarchive/test/test_read_format_cpio_bin_lzip.c index 4e3fb5872..2f98b0084 100644 --- a/libarchive/test/test_read_format_cpio_bin_lzip.c +++ b/libarchive/test/test_read_format_cpio_bin_lzip.c @@ -53,6 +53,8 @@ DEFINE_TEST(test_read_format_cpio_bin_lzip) assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, archive, sizeof(archive))); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_LZIP); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); diff --git a/libarchive/test/test_read_format_cpio_bin_lzma.c b/libarchive/test/test_read_format_cpio_bin_lzma.c index cca19ffa7..2b61542bf 100644 --- a/libarchive/test/test_read_format_cpio_bin_lzma.c +++ b/libarchive/test/test_read_format_cpio_bin_lzma.c @@ -54,6 +54,8 @@ DEFINE_TEST(test_read_format_cpio_bin_lzma) assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_LZMA); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_cpio_bin_xz.c b/libarchive/test/test_read_format_cpio_bin_xz.c index 2b5e6143c..11546cc1c 100644 --- a/libarchive/test/test_read_format_cpio_bin_xz.c +++ b/libarchive/test/test_read_format_cpio_bin_xz.c @@ -64,6 +64,8 @@ DEFINE_TEST(test_read_format_cpio_bin_xz) assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_XZ); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_cpio_filename.c b/libarchive/test/test_read_format_cpio_filename.c index d0c7c7afa..fc73c7ddd 100644 --- a/libarchive/test/test_read_format_cpio_filename.c +++ b/libarchive/test/test_read_format_cpio_filename.c @@ -57,11 +57,15 @@ test_read_format_cpio_filename_eucJP_UTF8(const char *refname) assertEqualString("\xe6\xbc\xa2\xe5\xad\x97.txt", archive_entry_pathname(ae)); assertEqualInt(8, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\xe8\xa1\xa8.txt", archive_entry_pathname(ae)); assertEqualInt(4, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ diff --git a/libarchive/test/test_read_format_cpio_odc.c b/libarchive/test/test_read_format_cpio_odc.c index c608bf045..ca22a836b 100644 --- a/libarchive/test/test_read_format_cpio_odc.c +++ b/libarchive/test/test_read_format_cpio_odc.c @@ -57,6 +57,8 @@ DEFINE_TEST(test_read_format_cpio_odc) assertEqualIntA(a, 0, archive_read_next_header(a, &ae)); assertA(archive_filter_code(a, 0) == ARCHIVE_FILTER_NONE); assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_POSIX); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c b/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c index d069da39e..7a01ee3d2 100644 --- a/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c +++ b/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c @@ -112,6 +112,8 @@ DEFINE_TEST(test_read_format_cpio_svr4_bzip2_rpm) assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("./etc/file3", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify the end-of-archive. */ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); diff --git a/libarchive/test/test_read_format_cpio_svr4_gzip.c b/libarchive/test/test_read_format_cpio_svr4_gzip.c index 9b9623464..0874be92c 100644 --- a/libarchive/test/test_read_format_cpio_svr4_gzip.c +++ b/libarchive/test/test_read_format_cpio_svr4_gzip.c @@ -54,6 +54,8 @@ DEFINE_TEST(test_read_format_cpio_svr4_gzip) ARCHIVE_FILTER_GZIP); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_NOCRC); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c b/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c index eccde65ad..3e6ae3146 100644 --- a/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c +++ b/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c @@ -112,6 +112,8 @@ DEFINE_TEST(test_read_format_cpio_svr4_gzip_rpm) assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("./etc/file3", archive_entry_pathname(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify the end-of-archive. */ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); diff --git a/libarchive/test/test_read_format_cpio_svr4c_Z.c b/libarchive/test/test_read_format_cpio_svr4c_Z.c index c33cd07ef..cc4ded5fe 100644 --- a/libarchive/test/test_read_format_cpio_svr4c_Z.c +++ b/libarchive/test/test_read_format_cpio_svr4c_Z.c @@ -51,6 +51,8 @@ DEFINE_TEST(test_read_format_cpio_svr4c_Z) assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_COMPRESS); failure("archive_format_name(a)=\"%s\"", archive_format_name(a)); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_CRC); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_empty.c b/libarchive/test/test_read_format_empty.c index c27d57ad5..63a5e5608 100644 --- a/libarchive/test/test_read_format_empty.c +++ b/libarchive/test/test_read_format_empty.c @@ -38,6 +38,8 @@ DEFINE_TEST(test_read_format_empty) assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae)); assertA(archive_filter_code(a, 0) == ARCHIVE_FILTER_NONE); assertA(archive_format(a) == ARCHIVE_FORMAT_EMPTY); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_gtar_filename.c b/libarchive/test/test_read_format_gtar_filename.c index 4b2a88c1e..64dc222ed 100644 --- a/libarchive/test/test_read_format_gtar_filename.c +++ b/libarchive/test/test_read_format_gtar_filename.c @@ -62,6 +62,8 @@ test_read_format_gtar_filename_eucJP_UTF8(const char *refname) assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\xe8\xa1\xa8.txt", archive_entry_pathname(ae)); assertEqualInt(4, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ diff --git a/libarchive/test/test_read_format_gtar_gz.c b/libarchive/test/test_read_format_gtar_gz.c index 8d60de007..7d5576eff 100644 --- a/libarchive/test/test_read_format_gtar_gz.c +++ b/libarchive/test/test_read_format_gtar_gz.c @@ -54,6 +54,8 @@ DEFINE_TEST(test_read_format_gtar_gz) assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_GZIP); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_gtar_lzma.c b/libarchive/test/test_read_format_gtar_lzma.c index 5dfbb2c22..8b66ef321 100644 --- a/libarchive/test/test_read_format_gtar_lzma.c +++ b/libarchive/test/test_read_format_gtar_lzma.c @@ -66,6 +66,8 @@ DEFINE_TEST(test_read_format_gtar_lzma) archive_read_next_header(a, &ae)); assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_LZMA); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); finish: assertEqualInt(ARCHIVE_OK, archive_read_free(a)); diff --git a/libarchive/test/test_read_format_gtar_sparse.c b/libarchive/test/test_read_format_gtar_sparse.c index 9a3511e9c..a7542314b 100644 --- a/libarchive/test/test_read_format_gtar_sparse.c +++ b/libarchive/test/test_read_format_gtar_sparse.c @@ -200,6 +200,8 @@ verify_archive_file(const char *name, struct archive_contents *ac) } failure("Name mismatch in archive %s", name); assertEqualString(ac->filename, archive_entry_pathname(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); expect = *cts++; while (0 == (err = archive_read_data_block(a, diff --git a/libarchive/test/test_read_format_iso_Z.c b/libarchive/test/test_read_format_iso_Z.c index 551e0cf34..74f2181e2 100644 --- a/libarchive/test/test_read_format_iso_Z.c +++ b/libarchive/test/test_read_format_iso_Z.c @@ -47,6 +47,8 @@ test1(void) assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_COMPRESS); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } @@ -88,6 +90,8 @@ test2(void) assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_COMPRESS); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_iso_multi_extent.c b/libarchive/test/test_read_format_iso_multi_extent.c index 63b5cf7ab..54b0c600f 100644 --- a/libarchive/test/test_read_format_iso_multi_extent.c +++ b/libarchive/test/test_read_format_iso_multi_extent.c @@ -73,6 +73,8 @@ DEFINE_TEST(test_read_format_iso_multi_extent) assertEqualInt(1, archive_entry_stat(ae)->st_nlink); assertEqualInt(1, archive_entry_uid(ae)); assertEqualInt(2, archive_entry_gid(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); } else { failure("Saw a file that shouldn't have been there"); assertEqualString(archive_entry_pathname(ae), ""); diff --git a/libarchive/test/test_read_format_iso_xorriso.c b/libarchive/test/test_read_format_iso_xorriso.c index 13502605a..8303c6bf6 100644 --- a/libarchive/test/test_read_format_iso_xorriso.c +++ b/libarchive/test/test_read_format_iso_xorriso.c @@ -86,6 +86,9 @@ DEFINE_TEST(test_read_format_iso_xorriso) for (i = 0; i < 10; ++i) { assertEqualInt(0, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); + if (strcmp(".", archive_entry_pathname(ae)) == 0) { /* '.' root directory. */ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); diff --git a/libarchive/test/test_read_format_isojoliet_bz2.c b/libarchive/test/test_read_format_isojoliet_bz2.c index 36239d121..8f35d3f17 100644 --- a/libarchive/test/test_read_format_isojoliet_bz2.c +++ b/libarchive/test/test_read_format_isojoliet_bz2.c @@ -83,6 +83,8 @@ DEFINE_TEST(test_read_format_isojoliet_bz2) assertEqualIntA(a, ARCHIVE_EOF, archive_read_data_block(a, &p, &size, &offset)); assertEqualInt((int)size, 0); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* A directory. */ assertEqualInt(0, archive_read_next_header(a, &ae)); @@ -91,6 +93,8 @@ DEFINE_TEST(test_read_format_isojoliet_bz2) assertEqualInt(2048, archive_entry_size(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(86401, archive_entry_atime(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* A regular file with two names ("hardlink" gets returned * first, so it's not marked as a hardlink). */ @@ -121,6 +125,8 @@ DEFINE_TEST(test_read_format_isojoliet_bz2) assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(172802, archive_entry_mtime(ae)); assertEqualInt(172802, archive_entry_atime(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae)); diff --git a/libarchive/test/test_read_format_isojoliet_long.c b/libarchive/test/test_read_format_isojoliet_long.c index 06f3f4fee..aad54e330 100644 --- a/libarchive/test/test_read_format_isojoliet_long.c +++ b/libarchive/test/test_read_format_isojoliet_long.c @@ -91,6 +91,8 @@ DEFINE_TEST(test_read_format_isojoliet_long) assertEqualIntA(a, ARCHIVE_EOF, archive_read_data_block(a, &p, &size, &offset)); assertEqualInt((int)size, 0); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* A directory. */ pathname[100] = 'd'; @@ -103,6 +105,8 @@ DEFINE_TEST(test_read_format_isojoliet_long) assertEqualInt(2048, archive_entry_size(ae)); assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(86401, archive_entry_atime(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* A regular file with two names (pathname gets returned * first, so it's not marked as a hardlink). */ @@ -119,6 +123,8 @@ DEFINE_TEST(test_read_format_isojoliet_long) assertEqualInt(6, (int)size); assertEqualInt(0, offset); assertEqualMem(p, "hello\n", 6); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Second name for the same regular file (this happens to be * returned second, so does get marked as a hardlink). */ @@ -127,6 +133,8 @@ DEFINE_TEST(test_read_format_isojoliet_long) assertEqualInt(AE_IFREG, archive_entry_filetype(ae)); assertEqualString("hardlink", archive_entry_hardlink(ae)); assert(!archive_entry_size_is_set(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae)); diff --git a/libarchive/test/test_read_format_isojoliet_rr.c b/libarchive/test/test_read_format_isojoliet_rr.c index ebf1b92d9..b5562f919 100644 --- a/libarchive/test/test_read_format_isojoliet_rr.c +++ b/libarchive/test/test_read_format_isojoliet_rr.c @@ -83,6 +83,8 @@ DEFINE_TEST(test_read_format_isojoliet_rr) assertEqualIntA(a, ARCHIVE_EOF, archive_read_data_block(a, &p, &size, &offset)); assertEqualInt((int)size, 0); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* A directory. */ assertEqualInt(0, archive_read_next_header(a, &ae)); @@ -94,6 +96,8 @@ DEFINE_TEST(test_read_format_isojoliet_rr) assertEqualInt(2, archive_entry_stat(ae)->st_nlink); assertEqualInt(1, archive_entry_uid(ae)); assertEqualInt(2, archive_entry_gid(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* A regular file with two names ("hardlink" gets returned * first, so it's not marked as a hardlink). */ @@ -116,6 +120,8 @@ DEFINE_TEST(test_read_format_isojoliet_rr) assertEqualInt(2, archive_entry_nlink(ae)); assertEqualInt(1, archive_entry_uid(ae)); assertEqualInt(2, archive_entry_gid(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Second name for the same regular file (this happens to be * returned second, so does get marked as a hardlink). */ @@ -132,6 +138,8 @@ DEFINE_TEST(test_read_format_isojoliet_rr) assertEqualInt(2, archive_entry_nlink(ae)); assertEqualInt(1, archive_entry_uid(ae)); assertEqualInt(2, archive_entry_gid(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* A symlink to the regular file. */ assertEqualInt(0, archive_read_next_header(a, &ae)); @@ -145,6 +153,8 @@ DEFINE_TEST(test_read_format_isojoliet_rr) assertEqualInt(1, archive_entry_nlink(ae)); assertEqualInt(1, archive_entry_uid(ae)); assertEqualInt(2, archive_entry_gid(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae)); diff --git a/libarchive/test/test_read_format_isojoliet_versioned.c b/libarchive/test/test_read_format_isojoliet_versioned.c index 8fa974b98..1b38f118c 100644 --- a/libarchive/test/test_read_format_isojoliet_versioned.c +++ b/libarchive/test/test_read_format_isojoliet_versioned.c @@ -58,6 +58,8 @@ DEFINE_TEST(test_read_format_isojoliet_versioned) assertEqualInt(0, archive_read_next_header(a, &ae)); assertEqualString("test", archive_entry_pathname(ae)); assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* A regular file which is called test.txt and has * ;1 appended to it because apparently Nero always @@ -69,6 +71,8 @@ DEFINE_TEST(test_read_format_isojoliet_versioned) assertEqualString("test/test.txt", archive_entry_pathname(ae)); assertEqualInt(AE_IFREG, archive_entry_filetype(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae)); diff --git a/libarchive/test/test_read_format_isorr_bz2.c b/libarchive/test/test_read_format_isorr_bz2.c index 1c16f3cb1..4c0e792f0 100644 --- a/libarchive/test/test_read_format_isorr_bz2.c +++ b/libarchive/test/test_read_format_isorr_bz2.c @@ -73,6 +73,9 @@ DEFINE_TEST(test_read_format_isorr_bz2) * verify that each one is what we expect. */ for (i = 0; i < 10; ++i) { assertEqualInt(0, archive_read_next_header(a, &ae)); + + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); if (strcmp(".", archive_entry_pathname(ae)) == 0) { /* '.' root directory. */ diff --git a/libarchive/test/test_read_format_isorr_ce.c b/libarchive/test/test_read_format_isorr_ce.c index c19864348..d0c1c5b63 100644 --- a/libarchive/test/test_read_format_isorr_ce.c +++ b/libarchive/test/test_read_format_isorr_ce.c @@ -109,6 +109,9 @@ DEFINE_TEST(test_read_format_isorr_ce) * verify that each one is what we expect. */ for (i = 0; i < 8; ++i) { assertEqualInt(0, archive_read_next_header(a, &ae)); + + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); if (strcmp(".", archive_entry_pathname(ae)) == 0) { /* '.' root directory. */ diff --git a/libarchive/test/test_read_format_isorr_new_bz2.c b/libarchive/test/test_read_format_isorr_new_bz2.c index 96fb05893..f5c21410f 100644 --- a/libarchive/test/test_read_format_isorr_new_bz2.c +++ b/libarchive/test/test_read_format_isorr_new_bz2.c @@ -74,6 +74,9 @@ DEFINE_TEST(test_read_format_isorr_new_bz2) * verify that each one is what we expect. */ for (i = 0; i < 10; ++i) { assertEqualInt(0, archive_read_next_header(a, &ae)); + + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); if (strcmp(".", archive_entry_pathname(ae)) == 0) { /* '.' root directory. */ diff --git a/libarchive/test/test_read_format_isorr_rr_moved.c b/libarchive/test/test_read_format_isorr_rr_moved.c index 57e7e1f85..db9c73695 100644 --- a/libarchive/test/test_read_format_isorr_rr_moved.c +++ b/libarchive/test/test_read_format_isorr_rr_moved.c @@ -80,6 +80,9 @@ DEFINE_TEST(test_read_format_isorr_rr_moved) for (i = 0; i < 13; ++i) { assertEqualInt(0, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); + if (strcmp(".", archive_entry_pathname(ae)) == 0) { /* '.' root directory. */ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); diff --git a/libarchive/test/test_read_format_isozisofs_bz2.c b/libarchive/test/test_read_format_isozisofs_bz2.c index 50ad32c70..4c12fa14c 100644 --- a/libarchive/test/test_read_format_isozisofs_bz2.c +++ b/libarchive/test/test_read_format_isozisofs_bz2.c @@ -73,6 +73,9 @@ DEFINE_TEST(test_read_format_isozisofs_bz2) for (i = 0; i < 8; ++i) { assertEqualInt(0, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); + if (strcmp(".", archive_entry_pathname(ae)) == 0) { /* '.' root directory. */ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); diff --git a/libarchive/test/test_read_format_lha.c b/libarchive/test/test_read_format_lha.c index 36c5d0803..7f443394b 100644 --- a/libarchive/test/test_read_format_lha.c +++ b/libarchive/test/test_read_format_lha.c @@ -169,6 +169,8 @@ verify(const char *refname, int posix) assertEqualIntA(a, ARCHIVE_EOF, archive_read_data_block(a, &pv, &s, &o)); assertEqualInt(s, 0); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify directory2. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); @@ -181,6 +183,8 @@ verify(const char *refname, int posix) assertEqualIntA(a, ARCHIVE_EOF, archive_read_data_block(a, &pv, &s, &o)); assertEqualInt(s, 0); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); if (posix) { /* Verify symbolic link file1. */ @@ -192,6 +196,8 @@ verify(const char *refname, int posix) assertEqualInt(uid, archive_entry_uid(ae)); assertEqualInt(gid, archive_entry_gid(ae)); assertEqualInt(0, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify symbolic link file2. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); @@ -202,6 +208,8 @@ verify(const char *refname, int posix) assertEqualInt(uid, archive_entry_uid(ae)); assertEqualInt(gid, archive_entry_gid(ae)); assertEqualInt(0, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); } /* Verify regular file1. */ @@ -214,6 +222,8 @@ verify(const char *refname, int posix) assertEqualInt(file1_size, archive_entry_size(ae)); assertEqualInt(file1_size, archive_read_data(a, buff, file1_size)); assertEqualMem(buff, file1, file1_size); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file2. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); @@ -228,6 +238,8 @@ verify(const char *refname, int posix) assertEqualInt(file2_size, archive_entry_size(ae)); assertEqualInt(file2_size, archive_read_data(a, buff, file2_size)); assertEqualMem(buff, file2, file2_size); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify the number of files read. */ if (posix) { @@ -245,6 +257,10 @@ verify(const char *refname, int posix) } else { assertEqualInt(4, archive_file_count(a)); } + + /* Verify encryption status */ + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify archive format. */ assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0)); diff --git a/libarchive/test/test_read_format_lha_filename.c b/libarchive/test/test_read_format_lha_filename.c index 67b6f3643..1c0681935 100644 --- a/libarchive/test/test_read_format_lha_filename.c +++ b/libarchive/test/test_read_format_lha_filename.c @@ -68,12 +68,15 @@ test_read_format_lha_filename_CP932_eucJP(const char *refname) assertEqualString("\xB4\xC1\xBB\xFA\x2E\x74\x78\x74", archive_entry_pathname(ae)); assertEqualInt(8, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\xC9\xBD\x2E\x74\x78\x74", archive_entry_pathname(ae)); assertEqualInt(4, archive_entry_size(ae)); - + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); diff --git a/libarchive/test/test_read_format_mtree.c b/libarchive/test/test_read_format_mtree.c index efedc415e..3a02c4410 100644 --- a/libarchive/test/test_read_format_mtree.c +++ b/libarchive/test/test_read_format_mtree.c @@ -76,63 +76,97 @@ test_read_format_mtree1(void) assertEqualInt(archive_entry_size(ae), 3); assertEqualInt(3, archive_read_data(a, buff, 3)); assertEqualMem(buff, "hi\n", 3); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir"); assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir/file with space"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "file with space"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/dir3a"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/dir3a/indir3a"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/fullindir2"); assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/indir2"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/dir3b"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/dir3b/indir3b"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "notindir"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/emptyfile"); assertEqualInt(archive_entry_size(ae), 0); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/smallfile"); assertEqualInt(archive_entry_size(ae), 1); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* TODO: Mtree reader should probably return ARCHIVE_WARN for this. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/toosmallfile"); assertEqualInt(archive_entry_size(ae), -1); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/bigfile"); assertEqualInt(archive_entry_size(ae), max_int64); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/toobigfile"); /* Size in mtree is max_int64 + 1; should return max_int64. */ assertEqualInt(archive_entry_size(ae), max_int64); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/veryoldfile"); @@ -143,12 +177,16 @@ test_read_format_mtree1(void) /* Simply asserting min_time - 1 > 0 breaks with some compiler optimizations. */ t = min_time - 1; assert(t > 0); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* toooldfile is 1 sec older, which should overflow and get returned * with the same value. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/toooldfile"); assertEqualInt(archive_entry_mtime(ae), min_time); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); assertEqualInt(19, archive_file_count(a)); @@ -176,6 +214,8 @@ test_read_format_mtree2(void) assertEqualInt(archive_format(a), ARCHIVE_FORMAT_MTREE); assertEqualString(archive_entry_pathname(ae), "d"); assertEqualInt(archive_entry_filetype(ae), AE_IFDIR); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); assertEqualInt(1, archive_file_count(a)); assertEqualInt(ARCHIVE_OK, archive_read_close(a)); @@ -210,12 +250,18 @@ test_read_format_mtree3(void) assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "a"); assertEqualInt(archive_entry_filetype(ae), AE_IFREG); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "b"); assertEqualInt(archive_entry_filetype(ae), AE_IFLNK); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "c"); assertEqualInt(archive_entry_filetype(ae), AE_IFREG); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); assertEqualInt(3, archive_file_count(a)); @@ -255,23 +301,35 @@ DEFINE_TEST(test_read_format_mtree_filenames_only) assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, archive, sizeof(archive))); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString(archive_entry_pathname(ae), "./a"); + assertEqualString(archive_entry_pathname(ae), "./a"); assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "./b"); assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "./c"); assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "./d"); assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "./e"); assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "./f"); assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0444); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); assertEqualInt(6, archive_file_count(a)); @@ -313,16 +371,22 @@ DEFINE_TEST(test_read_format_mtree_nochange) assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644); assertEqualInt(archive_entry_mtime(ae), 123); assertEqualInt(archive_entry_size(ae), 5); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "./b"); assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644); assertEqualInt(archive_entry_mtime(ae), 234); assertEqualInt(archive_entry_size(ae), 6); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "./c"); assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644); assertEqualInt(archive_entry_mtime(ae), 345); assertEqualInt(archive_entry_size(ae), 7); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); assertEqualInt(3, archive_file_count(a)); @@ -351,6 +415,8 @@ DEFINE_TEST(test_read_format_mtree_nochange) assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644); assertEqualInt(archive_entry_mtime(ae), 234); assertEqualInt(archive_entry_size(ae), 6); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "./c"); #if !defined(_WIN32) || defined(__CYGWIN__) @@ -358,6 +424,8 @@ DEFINE_TEST(test_read_format_mtree_nochange) #endif assert(archive_entry_mtime(ae) != 345); assertEqualInt(archive_entry_size(ae), 7); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); assertEqualInt(3, archive_file_count(a)); @@ -399,41 +467,65 @@ DEFINE_TEST(test_read_format_mtree_nomagic_v1_form) assertEqualInt(archive_entry_size(ae), 3); assertEqualInt(3, archive_read_data(a, buff, 3)); assertEqualMem(buff, "hi\n", 3); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir"); assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir/file with space"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "file with space"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/dir3a"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/dir3a/indir3a"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/fullindir2"); assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/indir2"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/dir3b"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/dir3b/indir3b"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "notindir"); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); assertEqualInt(12, archive_file_count(a)); diff --git a/libarchive/test/test_read_format_pax_bz2.c b/libarchive/test/test_read_format_pax_bz2.c index 48717fbd6..f26b04ed5 100644 --- a/libarchive/test/test_read_format_pax_bz2.c +++ b/libarchive/test/test_read_format_pax_bz2.c @@ -60,6 +60,8 @@ DEFINE_TEST(test_read_format_pax_bz2) assertEqualInt(1, archive_file_count(a)); assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_BZIP2); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a,ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_rar.c b/libarchive/test/test_read_format_rar.c index dc234e05f..e4e57f6ad 100644 --- a/libarchive/test/test_read_format_rar.c +++ b/libarchive/test/test_read_format_rar.c @@ -53,6 +53,8 @@ DEFINE_TEST(test_read_format_rar_basic) assertEqualInt(33188, archive_entry_mode(ae)); assertA(size == archive_read_data(a, buff, size)); assertEqualMem(buff, test_txt, size); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Second header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -64,6 +66,8 @@ DEFINE_TEST(test_read_format_rar_basic) assertEqualInt(41471, archive_entry_mode(ae)); assertEqualString("test.txt", archive_entry_symlink(ae)); assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff))); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Third header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -75,6 +79,8 @@ DEFINE_TEST(test_read_format_rar_basic) assertEqualInt(33188, archive_entry_mode(ae)); assertA(size == archive_read_data(a, buff, size)); assertEqualMem(buff, test_txt, size); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Fourth header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -84,6 +90,8 @@ DEFINE_TEST(test_read_format_rar_basic) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Fifth header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -93,6 +101,8 @@ DEFINE_TEST(test_read_format_rar_basic) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Test EOF */ assertA(1 == archive_read_next_header(a, &ae)); @@ -126,6 +136,8 @@ DEFINE_TEST(test_read_format_rar_subblock) assertEqualInt(33188, archive_entry_mode(ae)); assertA(size == archive_read_data(a, buff, size)); assertEqualMem(buff, test_txt, size); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Test EOF */ assertA(1 == archive_read_next_header(a, &ae)); @@ -159,6 +171,8 @@ DEFINE_TEST(test_read_format_rar_noeof) assertEqualInt(33188, archive_entry_mode(ae)); assertA(size == archive_read_data(a, buff, size)); assertEqualMem(buff, test_txt, size); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Test EOF */ assertA(1 == archive_read_next_header(a, &ae)); @@ -227,6 +241,8 @@ DEFINE_TEST(test_read_format_rar_unicode_UTF8) assertEqualInt(33188, archive_entry_mode(ae)); assertEqualIntA(a, 5, archive_read_data(a, buff, 5)); assertEqualMem(buff, test_txt, 5); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Third header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -273,6 +289,8 @@ DEFINE_TEST(test_read_format_rar_unicode_UTF8) assertA((int)archive_entry_mtime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(41453, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff))); /* Sixth header */ @@ -283,6 +301,8 @@ DEFINE_TEST(test_read_format_rar_unicode_UTF8) assertA((int)archive_entry_mtime(ae)); assertEqualInt(16, archive_entry_size(ae)); assertEqualInt(33204, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, 16, archive_read_data(a, buff, sizeof(buff))); /* Test EOF */ @@ -328,6 +348,8 @@ DEFINE_TEST(test_read_format_rar_unicode_CP932) assertA((int)archive_entry_mtime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Second header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -338,6 +360,8 @@ DEFINE_TEST(test_read_format_rar_unicode_CP932) assertA((int)archive_entry_mtime(ae)); assertEqualInt(5, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(5 == archive_read_data(a, buff, 5)); assertEqualMem(buff, test_txt, 5); @@ -349,6 +373,8 @@ DEFINE_TEST(test_read_format_rar_unicode_CP932) assertA((int)archive_entry_mtime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Fourth header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -356,6 +382,8 @@ DEFINE_TEST(test_read_format_rar_unicode_CP932) assertA((int)archive_entry_mtime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Fifth header, which has a symbolic-link name in multi-byte characters. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -368,6 +396,8 @@ DEFINE_TEST(test_read_format_rar_unicode_CP932) assertA((int)archive_entry_mtime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(41453, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff))); /* Sixth header */ @@ -378,6 +408,8 @@ DEFINE_TEST(test_read_format_rar_unicode_CP932) assertA((int)archive_entry_mtime(ae)); assertEqualInt(16, archive_entry_size(ae)); assertEqualInt(33204, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, 16, archive_read_data(a, buff, sizeof(buff))); /* Test EOF */ @@ -416,6 +448,8 @@ DEFINE_TEST(test_read_format_rar_compress_normal) assertA((int)archive_entry_atime(ae)); assertEqualInt(file1_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(file1_size == archive_read_data(a, file1_buff, file1_size)); assertEqualMem(&file1_buff[file1_size - sizeof(file1_test_txt) + 1], file1_test_txt, sizeof(file1_test_txt) - 1); @@ -428,6 +462,8 @@ DEFINE_TEST(test_read_format_rar_compress_normal) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(41471, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualString("LibarchiveAddingTest.html", archive_entry_symlink(ae)); assertEqualIntA(a, 0, archive_read_data(a, file1_buff, 30)); @@ -439,6 +475,8 @@ DEFINE_TEST(test_read_format_rar_compress_normal) assertA((int)archive_entry_atime(ae)); assertEqualInt(file2_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(file2_size == archive_read_data(a, file2_buff, file2_size)); assertEqualMem(&file2_buff[file2_size + 1 - sizeof(file2_test_txt)], file2_test_txt, sizeof(file2_test_txt) - 1); @@ -452,6 +490,8 @@ DEFINE_TEST(test_read_format_rar_compress_normal) assertA((int)archive_entry_atime(ae)); assertEqualInt(file1_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(file1_size == archive_read_data(a, file1_buff, file1_size)); assertEqualMem(&file1_buff[file1_size - sizeof(file1_test_txt) + 1], file1_test_txt, sizeof(file1_test_txt) - 1); @@ -464,6 +504,8 @@ DEFINE_TEST(test_read_format_rar_compress_normal) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Sixth header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -473,6 +515,8 @@ DEFINE_TEST(test_read_format_rar_compress_normal) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Test EOF */ assertA(1 == archive_read_next_header(a, &ae)); @@ -507,6 +551,8 @@ DEFINE_TEST(test_read_format_rar_multi_lzss_blocks) assertA((int)archive_entry_atime(ae)); assertEqualInt(size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); while (offset + (int)sizeof(buff) < size) { assertA(sizeof(buff) == archive_read_data(a, buff, sizeof(buff))); @@ -551,6 +597,8 @@ DEFINE_TEST(test_read_format_rar_compress_best) assertA((int)archive_entry_atime(ae)); assertEqualInt(file1_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(file1_size == archive_read_data(a, file1_buff, file1_size)); assertEqualMem(&file1_buff[file1_size - sizeof(file1_test_txt) + 1], file1_test_txt, sizeof(file1_test_txt) - 1); @@ -563,6 +611,8 @@ DEFINE_TEST(test_read_format_rar_compress_best) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(41471, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualString("LibarchiveAddingTest.html", archive_entry_symlink(ae)); assertEqualIntA(a, 0, archive_read_data(a, file1_buff, 30)); @@ -574,6 +624,8 @@ DEFINE_TEST(test_read_format_rar_compress_best) assertA((int)archive_entry_atime(ae)); assertEqualInt(file2_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(file2_size == archive_read_data(a, file2_buff, file2_size)); assertEqualMem(&file2_buff[file2_size + 1 - sizeof(file2_test_txt)], file2_test_txt, sizeof(file2_test_txt) - 1); @@ -587,6 +639,8 @@ DEFINE_TEST(test_read_format_rar_compress_best) assertA((int)archive_entry_atime(ae)); assertEqualInt(file1_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(file1_size == archive_read_data(a, file1_buff, file1_size)); assertEqualMem(&file1_buff[file1_size - sizeof(file1_test_txt) + 1], file1_test_txt, sizeof(file1_test_txt) - 1); @@ -599,6 +653,8 @@ DEFINE_TEST(test_read_format_rar_compress_best) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Sixth header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -608,6 +664,8 @@ DEFINE_TEST(test_read_format_rar_compress_best) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Test EOF */ assertA(1 == archive_read_next_header(a, &ae)); @@ -643,6 +701,8 @@ DEFINE_TEST(test_read_format_rar_ppmd_lzss_conversion) assertA((int)archive_entry_atime(ae)); assertEqualInt(size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); while (offset + (int)sizeof(buff) < size) { assertA(sizeof(buff) == archive_read_data(a, buff, sizeof(buff))); @@ -692,6 +752,8 @@ DEFINE_TEST(test_read_format_rar_binary) assertA((int)archive_entry_atime(ae)); assertEqualInt(file1_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(file1_size == archive_read_data(a, file1_buff, file1_size)); assertEqualMem(&file1_buff[file1_size - sizeof(file1_test_txt) + 1], file1_test_txt, sizeof(file1_test_txt) - 1); @@ -704,6 +766,8 @@ DEFINE_TEST(test_read_format_rar_binary) assertA((int)archive_entry_atime(ae)); assertEqualInt(file2_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(file2_size == archive_read_data(a, file2_buff, file2_size)); assertEqualMem(&file2_buff[file2_size + 1 - sizeof(file2_test_txt)], file2_test_txt, sizeof(file2_test_txt) - 1); @@ -738,6 +802,8 @@ DEFINE_TEST(test_read_format_rar_windows) assertA((int)archive_entry_atime(ae)); assertEqualInt(16, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(size == archive_read_data(a, buff, size)); assertEqualMem(buff, test_txt, size); @@ -749,6 +815,8 @@ DEFINE_TEST(test_read_format_rar_windows) assertA((int)archive_entry_atime(ae)); assertEqualInt(16, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(size == archive_read_data(a, buff, size)); assertEqualMem(buff, test_txt, size); @@ -760,6 +828,8 @@ DEFINE_TEST(test_read_format_rar_windows) assertA((int)archive_entry_atime(ae)); assertEqualInt(sizeof(buff), archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(sizeof(buff) == archive_read_data(a, buff, sizeof(buff))); /* Fourth header. */ @@ -770,6 +840,8 @@ DEFINE_TEST(test_read_format_rar_windows) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Fifth header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -779,6 +851,8 @@ DEFINE_TEST(test_read_format_rar_windows) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Test EOF */ assertA(1 == archive_read_next_header(a, &ae)); @@ -828,6 +902,8 @@ DEFINE_TEST(test_read_format_rar_multivolume) assertA((int)archive_entry_atime(ae)); assertEqualInt(file1_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); while (offset + (int)sizeof(buff) < file1_size) { assertA(sizeof(buff) == archive_read_data(a, buff, sizeof(buff))); @@ -845,6 +921,8 @@ DEFINE_TEST(test_read_format_rar_multivolume) assertA((int)archive_entry_atime(ae)); assertEqualInt(file2_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(file2_size == archive_read_data(a, file2_buff, file2_size)); assertEqualMem(&file2_buff[file2_size - sizeof(file2_test_txt) + 1], file2_test_txt, sizeof(file2_test_txt) - 1); @@ -857,6 +935,8 @@ DEFINE_TEST(test_read_format_rar_multivolume) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(41471, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualString("LibarchiveAddingTest.html", archive_entry_symlink(ae)); assertEqualIntA(a, 0, archive_read_data(a, file2_buff, 30)); @@ -868,6 +948,8 @@ DEFINE_TEST(test_read_format_rar_multivolume) assertA((int)archive_entry_atime(ae)); assertEqualInt(file3_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(file3_size == archive_read_data(a, file3_buff, file3_size)); assertEqualMem(&file3_buff[file3_size + 1 - sizeof(file3_test_txt)], file3_test_txt, sizeof(file3_test_txt) - 1); @@ -881,6 +963,8 @@ DEFINE_TEST(test_read_format_rar_multivolume) assertA((int)archive_entry_atime(ae)); assertEqualInt(file2_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(file2_size == archive_read_data(a, file2_buff, file2_size)); assertEqualMem(&file2_buff[file2_size - sizeof(file2_test_txt) + 1], file2_test_txt, sizeof(file2_test_txt) - 1); @@ -893,6 +977,8 @@ DEFINE_TEST(test_read_format_rar_multivolume) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Seventh header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -902,6 +988,8 @@ DEFINE_TEST(test_read_format_rar_multivolume) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Test EOF */ assertA(1 == archive_read_next_header(a, &ae)); @@ -941,6 +1029,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip) assertA((int)archive_entry_atime(ae)); assertEqualInt(file1_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Second header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -950,6 +1040,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip) assertA((int)archive_entry_atime(ae)); assertEqualInt(file2_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Third header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -959,6 +1051,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(41471, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualString("LibarchiveAddingTest.html", archive_entry_symlink(ae)); /* Fourth header. */ @@ -969,6 +1063,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip) assertA((int)archive_entry_atime(ae)); assertEqualInt(file3_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Fifth header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -979,6 +1075,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip) assertA((int)archive_entry_atime(ae)); assertEqualInt(file2_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Sixth header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -988,6 +1086,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Seventh header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -997,6 +1097,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Test EOF */ assertA(1 == archive_read_next_header(a, &ae)); @@ -1028,6 +1130,8 @@ DEFINE_TEST(test_read_format_rar_sfx) assertA((int)archive_entry_atime(ae)); assertEqualInt(16, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(size == archive_read_data(a, buff, size)); assertEqualMem(buff, test_txt, size); @@ -1039,6 +1143,8 @@ DEFINE_TEST(test_read_format_rar_sfx) assertA((int)archive_entry_atime(ae)); assertEqualInt(sizeof(buff), archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(sizeof(buff) == archive_read_data(a, buff, sizeof(buff))); /* Third header. */ @@ -1049,6 +1155,8 @@ DEFINE_TEST(test_read_format_rar_sfx) assertA((int)archive_entry_atime(ae)); assertEqualInt(16, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(size == archive_read_data(a, buff, size)); assertEqualMem(buff, test_txt, size); @@ -1060,6 +1168,8 @@ DEFINE_TEST(test_read_format_rar_sfx) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Fifth header. */ assertA(0 == archive_read_next_header(a, &ae)); @@ -1069,6 +1179,8 @@ DEFINE_TEST(test_read_format_rar_sfx) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Test EOF */ assertA(1 == archive_read_next_header(a, &ae)); @@ -1109,6 +1221,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_stored_file) assertA((int)archive_entry_atime(ae)); assertEqualInt(file_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertA(file_size == archive_read_data(a, file_buff, file_size)); assertEqualMem(&file_buff[file_size - sizeof(file_test_txt) + 1], file_test_txt, sizeof(file_test_txt) - 1); @@ -1147,6 +1261,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_stored_file_skip) assertA((int)archive_entry_atime(ae)); assertEqualInt(file_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Test EOF */ assertA(1 == archive_read_next_header(a, &ae)); @@ -1193,6 +1309,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_seek_data) assertA((int)archive_entry_atime(ae)); assertEqualInt(file_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Seek to the end minus 64 bytes */ assertA(file_size - (int)sizeof(buff) == @@ -1331,6 +1449,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_seek_multiple_files) assertA((int)archive_entry_atime(ae)); assertEqualInt(file_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Attempt to read past end of file */ assertEqualInt(file_size, archive_seek_data(a, 0, SEEK_END)); @@ -1379,6 +1499,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_seek_multiple_files) assertA((int)archive_entry_atime(ae)); assertEqualInt(file_size, archive_entry_size(ae)); assertEqualInt(33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Attempt to read past end of file */ assertEqualInt(file_size, archive_seek_data(a, 0, SEEK_END)); @@ -1523,6 +1645,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertA((int)archive_entry_atime(ae)); assertEqualIntA(a, 20111, archive_entry_size(ae)); assertEqualIntA(a, 33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); test_read_format_rar_multivolume_uncompressed_files_helper(a); @@ -1786,6 +1910,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertA((int)archive_entry_atime(ae)); assertEqualIntA(a, 20111, archive_entry_size(ae)); assertEqualIntA(a, 33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); test_read_format_rar_multivolume_uncompressed_files_helper(a); @@ -2169,6 +2295,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertA((int)archive_entry_atime(ae)); assertEqualIntA(a, 20111, archive_entry_size(ae)); assertEqualIntA(a, 33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); test_read_format_rar_multivolume_uncompressed_files_helper(a); @@ -2432,6 +2560,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertA((int)archive_entry_atime(ae)); assertEqualIntA(a, 20111, archive_entry_size(ae)); assertEqualIntA(a, 33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); test_read_format_rar_multivolume_uncompressed_files_helper(a); @@ -2815,6 +2945,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertA((int)archive_entry_atime(ae)); assertEqualIntA(a, 20111, archive_entry_size(ae)); assertEqualIntA(a, 33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); test_read_format_rar_multivolume_uncompressed_files_helper(a); @@ -3078,6 +3210,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertA((int)archive_entry_atime(ae)); assertEqualIntA(a, 20111, archive_entry_size(ae)); assertEqualIntA(a, 33188, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); test_read_format_rar_multivolume_uncompressed_files_helper(a); @@ -3462,6 +3596,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertEqualInt(41471, archive_entry_mode(ae)); assertEqualString("testsubdir/LibarchiveAddingTest.html", archive_entry_symlink(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff))); /* @@ -3476,6 +3612,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertEqualInt(41471, archive_entry_mode(ae)); assertEqualString("testsubdir/LibarchiveAddingTest2.html", archive_entry_symlink(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff))); /* @@ -3490,6 +3628,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertEqualInt(41471, archive_entry_mode(ae)); assertEqualString("testdir/LibarchiveAddingTest.html", archive_entry_symlink(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff))); /* @@ -3504,6 +3644,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertEqualInt(41471, archive_entry_mode(ae)); assertEqualString("testdir/LibarchiveAddingTest2.html", archive_entry_symlink(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff))); /* @@ -3518,6 +3660,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertEqualInt(41471, archive_entry_mode(ae)); assertEqualString("testdir/testsubdir/LibarchiveAddingTest.html", archive_entry_symlink(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff))); /* @@ -3532,6 +3676,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertEqualInt(41471, archive_entry_mode(ae)); assertEqualString("testdir/testsubdir/LibarchiveAddingTest2.html", archive_entry_symlink(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff))); /* @@ -3544,6 +3690,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* * Fourteenth header. @@ -3555,6 +3703,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* * Fifteenth header. @@ -3566,6 +3716,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* * Sixteenth header. @@ -3577,6 +3729,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files) assertA((int)archive_entry_atime(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualInt(16877, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Test EOF */ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); diff --git a/libarchive/test/test_read_format_rar_encryption_data.c b/libarchive/test/test_read_format_rar_encryption_data.c new file mode 100644 index 000000000..14de888ad --- /dev/null +++ b/libarchive/test/test_read_format_rar_encryption_data.c @@ -0,0 +1,79 @@ +/*- + * Copyright (c) 2013 Konrad Kleine + * 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$"); + +DEFINE_TEST(test_read_format_rar_encryption_data) +{ + /* This file is password protected (encrypted). The headers + are NOT encrypted. Password is "12345678". */ + const char *refname = "test_read_format_rar_encryption_data.rar"; + struct archive_entry *ae; + struct archive *a; + char buff[128]; + + extract_reference_file(refname); + 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)); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_open_filename(a, refname, 10240)); + + /* Verify encrypted file "foo.txt" */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae)); + assertEqualString("foo.txt", archive_entry_pathname(ae)); + assertEqualInt(1379403430, archive_entry_mtime(ae)); + assertEqualInt(16, archive_entry_size(ae)); + assertEqualInt(1, archive_entry_is_data_encrypted(ae)); + assertEqualInt(0, archive_entry_is_metadata_encrypted(ae)); + assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a)); + assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff))); + + /* Verify encrypted file "bar.txt" */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae)); + assertEqualString("bar.txt", archive_entry_pathname(ae)); + assertEqualInt(1379403432, archive_entry_mtime(ae)); + assertEqualInt(16, archive_entry_size(ae)); + assertEqualInt(1, archive_entry_is_data_encrypted(ae)); + assertEqualInt(0, archive_entry_is_metadata_encrypted(ae)); + assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a)); + assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff))); + + assertEqualInt(2, archive_file_count(a)); + + /* End of archive. */ + assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + + /* Verify archive format. */ + assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0)); + assertEqualIntA(a, ARCHIVE_FORMAT_RAR, archive_format(a)); + + /* Close the archive. */ + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} + diff --git a/libarchive/test/test_read_format_rar_encryption_data.rar.uu b/libarchive/test/test_read_format_rar_encryption_data.rar.uu new file mode 100644 index 000000000..793e23766 --- /dev/null +++ b/libarchive/test/test_read_format_rar_encryption_data.rar.uu @@ -0,0 +1,8 @@ +begin 664 test_read_format_rar_encryption_data.rar +M4F%R(1H'`,^0'1/`[S9UA9,WT5`&I*2B-\5*XZ>SW"Y0.C)1^;.UK]$ +MXK@UJ)SH93P!`!P`` +` +end diff --git a/libarchive/test/test_read_format_rar_encryption_header.c b/libarchive/test/test_read_format_rar_encryption_header.c new file mode 100644 index 000000000..71de49de5 --- /dev/null +++ b/libarchive/test/test_read_format_rar_encryption_header.c @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 2013 Konrad Kleine + * 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$"); + +DEFINE_TEST(test_read_format_rar_encryption_header) +{ + /* This file is password protected (encrypted) with AES-256. The headers + ARE encrypted. Password is "12345678". */ + const char *refname = "test_read_format_rar_encryption_header.rar"; + struct archive_entry *ae; + struct archive *a; + char buff[128]; + + extract_reference_file(refname); + 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)); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_open_filename(a, refname, 10240)); + + /* Verify regular file but with encrypted headers + as a consequence, all meta information is invalid. */ + assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae)); + + assertEqualInt(0, archive_entry_mode(ae)); + assertEqualString(NULL, archive_entry_pathname(ae)); + assertEqualInt(0, archive_entry_mtime(ae)); + assertEqualInt(0, archive_entry_size(ae)); + assertEqualInt(1, archive_entry_is_data_encrypted(ae)); + assertEqualInt(1, archive_entry_is_metadata_encrypted(ae)); + assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a)); + assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff))); + + assertEqualInt(1, archive_file_count(a)); + + /* End of archive. */ + assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae)); + + /* Verify archive format. */ + assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0)); + assertEqualIntA(a, ARCHIVE_FORMAT_RAR, archive_format(a)); + + /* Close the archive. */ + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} diff --git a/libarchive/test/test_read_format_rar_encryption_header.rar.uu b/libarchive/test/test_read_format_rar_encryption_header.rar.uu new file mode 100644 index 000000000..5bd48d7a5 --- /dev/null +++ b/libarchive/test/test_read_format_rar_encryption_header.rar.uu @@ -0,0 +1,8 @@ +begin 664 test_read_format_rar_encryption_header.rar +M4F%R(1H'`,Z91EQMQ=@1S +M,[$:0Y\;'G8_C0D%2L":*;.B*LM0!,!.2!RBU?+`DTN9KXD\<4RGSC+#KCC:\R +M$)P&_/D2I'(4,7$^#2[\,Y"D.2T$@B1#J-Z$]R6_*($W7+!JH\,(XH,'C7FC +H@B,\$1>+CX-=`-%F3C6%I^,NJV2G7':,JF?4KS:6=TAK%$V=]2+N^@`` +` +end diff --git a/libarchive/test/test_read_format_rar_encryption_partially.c b/libarchive/test/test_read_format_rar_encryption_partially.c new file mode 100644 index 000000000..3b13103bd --- /dev/null +++ b/libarchive/test/test_read_format_rar_encryption_partially.c @@ -0,0 +1,79 @@ +/*- + * Copyright (c) 2013 Konrad Kleine + * 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$"); + +DEFINE_TEST(test_read_format_rar_encryption_partially) +{ + /* This file contains one file that is encrypted (foo.txt, password=12345678) + and one file that is not encrypted (bar.txt) The header is not encrypted + on this file. */ + const char *refname = "test_read_format_rar_encryption_partially.rar"; + struct archive_entry *ae; + struct archive *a; + char buff[128]; + + extract_reference_file(refname); + 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)); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_open_filename(a, refname, 10240)); + + /* Verify encrypted file "foo.txt". */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae)); + assertEqualString("foo.txt", archive_entry_pathname(ae)); + assertEqualInt(1379403430, archive_entry_mtime(ae)); + assertEqualInt(16, archive_entry_size(ae)); + assertEqualInt(1, archive_entry_is_data_encrypted(ae)); + assertEqualInt(0, archive_entry_is_metadata_encrypted(ae)); + assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a)); + assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff))); + + /* Verify unencrypted file "bar.txt". */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae)); + assertEqualString("bar.txt", archive_entry_pathname(ae)); + assertEqualInt(1379403432, archive_entry_mtime(ae)); + assertEqualInt(16, archive_entry_size(ae)); + assertEqualInt(0, archive_entry_is_data_encrypted(ae)); + assertEqualInt(0, archive_entry_is_metadata_encrypted(ae)); + assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a)); + assertEqualInt(16, archive_read_data(a, buff, sizeof(buff))); + + assertEqualInt(2, archive_file_count(a)); + + /* End of archive. */ + assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + + /* Verify archive format. */ + assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0)); + assertEqualIntA(a, ARCHIVE_FORMAT_RAR, archive_format(a)); + + /* Close the archive. */ + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} diff --git a/libarchive/test/test_read_format_rar_encryption_partially.rar.uu b/libarchive/test/test_read_format_rar_encryption_partially.rar.uu new file mode 100644 index 000000000..0c9727f1a --- /dev/null +++ b/libarchive/test/test_read_format_rar_encryption_partially.rar.uu @@ -0,0 +1,7 @@ +begin 664 test_read_format_rar_encryption_partially.rar +M4F%R(1H'`,^0'2>C_^E6-T51TBV:OLN/8KJ<5S5/Y4G6N&PG<5GX;P= +MF_YJK^@\`3\09C!T((`G`!P````0`````[[BD,VF3#%#'3,'`+2!``!B87(N +F='AT#!#)/HRW]%5!"GXA#4D)_]J&++4FP^?OH,0]>P!`!P`` +` +end diff --git a/libarchive/test/test_read_format_raw.c b/libarchive/test/test_read_format_raw.c index a23b9c55a..ed130bf50 100644 --- a/libarchive/test/test_read_format_raw.c +++ b/libarchive/test/test_read_format_raw.c @@ -53,6 +53,8 @@ DEFINE_TEST(test_read_format_raw) assert(!archive_entry_atime_is_set(ae)); assert(!archive_entry_ctime_is_set(ae)); assert(!archive_entry_mtime_is_set(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(4, archive_read_data(a, buff, 32)); assertEqualMem(buff, "foo\n", 4); @@ -74,6 +76,8 @@ DEFINE_TEST(test_read_format_raw) /* First (and only!) Entry */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("data", archive_entry_pathname(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Most fields should be unset (unknown) */ assert(!archive_entry_size_is_set(ae)); assert(!archive_entry_atime_is_set(ae)); diff --git a/libarchive/test/test_read_format_tar.c b/libarchive/test/test_read_format_tar.c index 8273e7530..aa0735b82 100644 --- a/libarchive/test/test_read_format_tar.c +++ b/libarchive/test/test_read_format_tar.c @@ -74,6 +74,8 @@ static void verifyEmpty(void) assertEqualString(archive_filter_name(a, 0), "none"); failure("512 zero bytes should be recognized as a tar archive."); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); @@ -439,6 +441,8 @@ static void verify(unsigned char *d, size_t s, assertA(0 == archive_read_next_header(a, &ae)); assertEqualInt(archive_filter_code(a, 0), compression); assertEqualInt(archive_format(a), format); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify the only entry. */ f(ae); diff --git a/libarchive/test/test_read_format_tar_empty_filename.c b/libarchive/test/test_read_format_tar_empty_filename.c index d7c8105a4..ec047834e 100644 --- a/libarchive/test/test_read_format_tar_empty_filename.c +++ b/libarchive/test/test_read_format_tar_empty_filename.c @@ -49,6 +49,8 @@ DEFINE_TEST(test_read_format_tar_empty_filename) assertEqualInt(0, archive_entry_gid(ae)); assertEqualString("wheel", archive_entry_gname(ae)); assertEqualInt(040775, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify the end-of-archive. */ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); diff --git a/libarchive/test/test_read_format_tar_empty_pax.c b/libarchive/test/test_read_format_tar_empty_pax.c index c6b5741ec..fcdc48e35 100644 --- a/libarchive/test/test_read_format_tar_empty_pax.c +++ b/libarchive/test/test_read_format_tar_empty_pax.c @@ -49,6 +49,8 @@ DEFINE_TEST(test_read_format_tar_empty_pax) assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 10240)); assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(ARCHIVE_FILTER_COMPRESS, archive_filter_code(a, 0)); assertEqualInt(ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE, archive_format(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); diff --git a/libarchive/test/test_read_format_tar_filename.c b/libarchive/test/test_read_format_tar_filename.c index ee2bf81de..e50880a83 100644 --- a/libarchive/test/test_read_format_tar_filename.c +++ b/libarchive/test/test_read_format_tar_filename.c @@ -80,12 +80,16 @@ test_read_format_tar_filename_KOI8R_CP866(const char *refname) assertEqualString("\x8f\x90\x88\x82\x85\x92", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular second file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\xaf\xe0\xa8\xa2\xa5\xe2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ @@ -123,6 +127,8 @@ next_test: assertEqualString("\xf0\xf2\xe9\xf7\xe5\xf4", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* * Verify regular second file. @@ -132,6 +138,8 @@ next_test: assertEqualString("\xaf\xe0\xa8\xa2\xa5\xe2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ @@ -179,13 +187,20 @@ test_read_format_tar_filename_KOI8R_UTF8(const char *refname) assertEqualString("\xd0\x9f\xd0\xa0\xd0\x98\xd0\x92\xd0\x95\xd0\xa2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); + /* Verify encryption status */ + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); @@ -194,6 +209,10 @@ test_read_format_tar_filename_KOI8R_UTF8(const char *refname) assertEqualIntA(a, ARCHIVE_FILTER_COMPRESS, archive_filter_code(a, 0)); assertEqualIntA(a, ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE, archive_format(a)); + + /* Verify encryption status */ + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Close the archive. */ assertEqualInt(ARCHIVE_OK, archive_read_close(a)); @@ -220,6 +239,10 @@ test_read_format_tar_filename_KOI8R_UTF8(const char *refname) assertEqualString("\xf0\xf2\xe9\xf7\xe5\xf4", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + + /* Verify encryption status */ + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* * Verify regular second file. @@ -286,12 +309,16 @@ test_read_format_tar_filename_KOI8R_CP1251(const char *refname) assertEqualString("\xcf\xd0\xc8\xc2\xc5\xd2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular second file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ @@ -328,6 +355,8 @@ next_test: assertEqualString("\xf0\xf2\xe9\xf7\xe5\xf4", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* * Verify regular second file. @@ -336,6 +365,8 @@ next_test: assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ diff --git a/libarchive/test/test_read_format_tbz.c b/libarchive/test/test_read_format_tbz.c index 475c558ee..304705104 100644 --- a/libarchive/test/test_read_format_tbz.c +++ b/libarchive/test/test_read_format_tbz.c @@ -53,6 +53,8 @@ DEFINE_TEST(test_read_format_tbz) assertEqualInt(1, archive_file_count(a)); assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_BZIP2); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_tgz.c b/libarchive/test/test_read_format_tgz.c index 60985a0d9..3294c318b 100644 --- a/libarchive/test/test_read_format_tgz.c +++ b/libarchive/test/test_read_format_tgz.c @@ -54,6 +54,8 @@ DEFINE_TEST(test_read_format_tgz) assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_GZIP); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualInt(ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK,archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_tlz.c b/libarchive/test/test_read_format_tlz.c index 2a058d039..f7c4b06c5 100644 --- a/libarchive/test/test_read_format_tlz.c +++ b/libarchive/test/test_read_format_tlz.c @@ -56,6 +56,8 @@ DEFINE_TEST(test_read_format_tlz) assertEqualInt(1, archive_file_count(a)); assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_LZMA); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_txz.c b/libarchive/test/test_read_format_txz.c index 6672ad2f0..d57046537 100644 --- a/libarchive/test/test_read_format_txz.c +++ b/libarchive/test/test_read_format_txz.c @@ -59,6 +59,8 @@ DEFINE_TEST(test_read_format_txz) assertEqualInt(1, archive_file_count(a)); assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_XZ); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_tz.c b/libarchive/test/test_read_format_tz.c index 60d8a4e61..d2240dbae 100644 --- a/libarchive/test/test_read_format_tz.c +++ b/libarchive/test/test_read_format_tz.c @@ -51,6 +51,8 @@ DEFINE_TEST(test_read_format_tz) assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_COMPRESS); failure("archive_format_name(a)=\"%s\"", archive_format_name(a)); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_ustar_filename.c b/libarchive/test/test_read_format_ustar_filename.c index f2e577d0a..b32047f5e 100644 --- a/libarchive/test/test_read_format_ustar_filename.c +++ b/libarchive/test/test_read_format_ustar_filename.c @@ -57,12 +57,16 @@ test_read_format_ustar_filename_eucJP_UTF8(const char *refname) assertEqualString("\xe6\xbc\xa2\xe5\xad\x97.txt", archive_entry_pathname(ae)); assertEqualInt(8, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\xe8\xa1\xa8.txt", archive_entry_pathname(ae)); assertEqualInt(4, archive_entry_size(ae)); - + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); + /* End of archive. */ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); @@ -108,13 +112,17 @@ test_read_format_ustar_filename_CP866_KOI8R(const char *refname) assertEqualString("\xf0\xf2\xe9\xf7\xe5\xf4", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\xd0\xd2\xc9\xd7\xc5\xd4", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); - + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); + /* End of archive. */ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); @@ -159,12 +167,16 @@ test_read_format_ustar_filename_CP866_UTF8(const char *refname) assertEqualString("\xd0\x9f\xd0\xa0\xd0\x98\xd0\x92\xd0\x95\xd0\xa2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ @@ -211,12 +223,16 @@ test_read_format_ustar_filename_KOI8R_CP866(const char *refname) assertEqualString("\xaf\xe0\xa8\xa2\xa5\xe2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\x8f\x90\x88\x82\x85\x92", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ @@ -262,12 +278,16 @@ test_read_format_ustar_filename_KOI8R_UTF8(const char *refname) assertEqualString("\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\xd0\x9f\xd0\xa0\xd0\x98\xd0\x92\xd0\x95\xd0\xa2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ @@ -313,11 +333,15 @@ test_read_format_ustar_filename_eucJP_CP932(const char *refname) assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\x8a\xbf\x8e\x9a.txt", archive_entry_pathname(ae)); assertEqualInt(8, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\x95\x5c.txt", archive_entry_pathname(ae)); assertEqualInt(4, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ @@ -364,12 +388,16 @@ test_read_format_ustar_filename_CP866_CP1251(const char *refname) assertEqualString("\xcf\xd0\xc8\xc2\xc5\xd2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ @@ -416,12 +444,16 @@ test_read_format_ustar_filename_CP866_CP1251_win(const char *refname) assertEqualString("\xcf\xd0\xc8\xc2\xc5\xd2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ @@ -467,12 +499,16 @@ test_read_format_ustar_filename_KOI8R_CP1251(const char *refname) assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify regular file. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("\xcf\xd0\xc8\xc2\xc5\xd2", archive_entry_pathname(ae)); assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* End of archive. */ diff --git a/libarchive/test/test_read_format_xar.c b/libarchive/test/test_read_format_xar.c index f2de1e013..e6bc3511b 100644 --- a/libarchive/test/test_read_format_xar.c +++ b/libarchive/test/test_read_format_xar.c @@ -663,6 +663,8 @@ static void verify(unsigned char *d, size_t s, assertA(0 == archive_read_next_header(a, &ae)); assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_NONE); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_XAR); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); /* Verify the only entry. */ f1(a, ae); if (f2) { diff --git a/libarchive/test/test_read_format_zip.c b/libarchive/test/test_read_format_zip.c index 7f3568157..7df25ec2b 100644 --- a/libarchive/test/test_read_format_zip.c +++ b/libarchive/test/test_read_format_zip.c @@ -52,6 +52,8 @@ verify_basic(struct archive *a, int seek_checks) assertEqualInt(0, archive_entry_size(ae)); if (seek_checks) assertEqualInt(AE_IFDIR | 0755, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_EOF, archive_read_data_block(a, &pv, &s, &o)); assertEqualInt((int)s, 0); @@ -62,6 +64,8 @@ verify_basic(struct archive *a, int seek_checks) if (seek_checks) assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae)); assertEqualInt(18, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); failure("archive_read_data() returns number of bytes read"); if (libz_enabled) { assertEqualInt(18, archive_read_data(a, buff, 19)); @@ -76,6 +80,8 @@ verify_basic(struct archive *a, int seek_checks) assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("file2", archive_entry_pathname(ae)); assertEqualInt(1179605932, archive_entry_mtime(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); if (seek_checks) { assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae)); assertEqualInt(64, archive_entry_size_is_set(ae)); @@ -144,6 +150,8 @@ verify_info_zip_ux(struct archive *a, int seek_checks) assertEqualString("file1", archive_entry_pathname(ae)); assertEqualInt(1300668680, archive_entry_mtime(ae)); assertEqualInt(18, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); if (seek_checks) assertEqualInt(AE_IFREG | 0644, archive_entry_mode(ae)); failure("zip reader should read Info-ZIP New Unix Extra Field"); @@ -208,6 +216,8 @@ verify_extract_length_at_end(struct archive *a, int seek_checks) assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualString("hello.txt", archive_entry_pathname(ae)); if (seek_checks) { assertEqualInt(AE_IFREG | 0644, archive_entry_mode(ae)); @@ -278,12 +288,16 @@ test_symlink(void) assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("file", archive_entry_pathname(ae)); assertEqualInt(AE_IFREG, archive_entry_filetype(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("symlink", archive_entry_pathname(ae)); assertEqualInt(AE_IFLNK, archive_entry_filetype(ae)); assertEqualInt(0, archive_entry_size(ae)); assertEqualString("file", archive_entry_symlink(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); diff --git a/libarchive/test/test_read_format_zip_comment_stored.c b/libarchive/test/test_read_format_zip_comment_stored.c index 5394cebc0..5d7014d9d 100644 --- a/libarchive/test/test_read_format_zip_comment_stored.c +++ b/libarchive/test/test_read_format_zip_comment_stored.c @@ -48,15 +48,21 @@ verify(const char *refname) assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("file0", archive_entry_pathname(ae)); assertEqualInt(AE_IFREG | 0644, archive_entry_mode(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString("build.sh", archive_entry_pathname(ae)); assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae)); assertEqualInt(23, archive_entry_size(ae)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); 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)); + assertEqualInt(archive_entry_is_encrypted(ae), 0); + assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0); } DEFINE_TEST(test_read_format_zip_comment_stored) diff --git a/libarchive/test/test_read_format_zip_encryption_data.c b/libarchive/test/test_read_format_zip_encryption_data.c new file mode 100644 index 000000000..c4585a188 --- /dev/null +++ b/libarchive/test/test_read_format_zip_encryption_data.c @@ -0,0 +1,79 @@ +/*- + * Copyright (c) 2013 Konrad Kleine + * 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$"); + +DEFINE_TEST(test_read_format_zip_encryption_data) +{ + /* This file is password protected (encrypted). The headers + are NOT encrypted. Password is "12345678". */ + const char *refname = "test_read_format_zip_encryption_data.zip"; + struct archive_entry *ae; + struct archive *a; + char buff[128]; + + extract_reference_file(refname); + 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)); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_open_filename(a, refname, 10240)); + + /* Verify encrypted file "bar.txt" */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt((AE_IFREG | 0666), archive_entry_mode(ae)); + assertEqualString("bar.txt", archive_entry_pathname(ae)); + assertEqualInt(1379416406, archive_entry_mtime(ae)); + assertEqualInt(20, archive_entry_size(ae)); + assertEqualInt(1, archive_entry_is_data_encrypted(ae)); + assertEqualInt(0, archive_entry_is_metadata_encrypted(ae)); + assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a)); + assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, sizeof(buff))); + + /* Verify encrypted file "foo.txt" */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt((AE_IFREG | 0666), archive_entry_mode(ae)); + assertEqualString("foo.txt", archive_entry_pathname(ae)); + assertEqualInt(1379416400, archive_entry_mtime(ae)); + assertEqualInt(20, archive_entry_size(ae)); + assertEqualInt(1, archive_entry_is_data_encrypted(ae)); + assertEqualInt(0, archive_entry_is_metadata_encrypted(ae)); + assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a)); + assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, sizeof(buff))); + + assertEqualInt(2, archive_file_count(a)); + + /* End of archive. */ + assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + + /* Verify archive format. */ + assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0)); + assertEqualIntA(a, ARCHIVE_FORMAT_ZIP, archive_format(a)); + + /* Close the archive. */ + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} + diff --git a/libarchive/test/test_read_format_zip_encryption_data.zip.uu b/libarchive/test/test_read_format_zip_encryption_data.zip.uu new file mode 100644 index 000000000..d419e7d6d --- /dev/null +++ b/libarchive/test/test_read_format_zip_encryption_data.zip.uu @@ -0,0 +1,25 @@ +begin 664 test_read_format_zip_encryption_data.zip +M4$L#!#,`00```*UI,4/H*IFA5@$``!0````'````8F%R+G1X=!``2#/PIQFT +M*F$4U*$#L8[-?B`!```#`!!F``$!`)``[SL/J;#"+JV#-X^_V7R?(/NINR^)*Z@-`+PM+G'_/G,@= +MOQI>T\*I"7FDH^[+/([/S3(S=2JR^B1VT7NV=\PU*ILZ(S-9P@#K>HTK<9$X +MG?3>):QUHT4^7JY*;B_X.,6FCSB0]-;K-:!W"\9#7%JT`````(``I>M3N%RW +MKHT3'HV+V7'\SG*),5W`7P-"J01^*X5F-K&;`\FXL%S[!!"J1 +M?4B:)(8&4)C/_^4!TF+`7W`%52=)VJ9U?3H,W@"9S8062TGSY_<:.\=X_SCC +M1?,I!IE@=&J39?KX5+0Y\Y`;^.[MR@]TB?WG-.D/]RONSJ(6 +MMAL3^^^V;)?](;*EA#%$TN]?2U!+`P0S`$$```"J:3%#_\P&4E8!```4```` +M!P```&9O;RYT>'00`(N/OW)U+.F;D#0D]']<[0I5,5G^P3D\Q/LN'ME\GR#[J;LOB2NH +M#7-Y7/%J"13'@"\+2YQ_SYS(';\:7M/"J0EYI*/NRSR.S\TR,W4JLOHD=M%[ +MMG?,-2J;.B,S6<(`ZWJ-*W&1.)WTWB6L=:-%/EZN2FXO^#C%IH\XD/36ZS6@ +M=PO&0UQ:M`````"``".OX15'_!K.OGAW6+M]C;[G8@26,FBSB&/46Q@#[301 +M`"51%C)3[11_TP#)7O_6`&/F?FGG]G9;W.L$";H2&[ +ML$PNS#NDG9Q@BFL$`&S?S3;,D#OS#% +MZ>O6I=M41I^&XX"JLTTKLW]*B=+>(C]+6]H**#DX_EJ;9BBY;,=02P$"0``S +M`$$```"M:3%#Z"J9H58!```4````!P`T```````!`"``````````8F%R+G1X +M=`H`(````````0`8`".@Q.V6L\X!(Z#$[9:SS@$CH,3MEK/.`1<`#``"`!!F +M``$!``````!02P$"0``S`$$```"J:3%#_\P&4E8!```4````!P`T```````! +M`"````![`0``9F]O+G1X=`H`(````````0`8`"4C6.F6L\X!)2-8Z9:SS@$E +M(UCIEK/.`1<`#``"`!!F``$!``````!02P4&``````(``@#2````]@(````` +` +end diff --git a/libarchive/test/test_read_format_zip_encryption_header.c b/libarchive/test/test_read_format_zip_encryption_header.c new file mode 100644 index 000000000..5776db8b3 --- /dev/null +++ b/libarchive/test/test_read_format_zip_encryption_header.c @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 2013 Konrad Kleine + * 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$"); + +DEFINE_TEST(test_read_format_zip_encryption_header) +{ + /* This file is password protected (encrypted) with AES-256. The headers + ARE encrypted. Password is "12345678". */ + const char *refname = "test_read_format_zip_encryption_header.zip"; + struct archive_entry *ae; + struct archive *a; + char buff[128]; + + extract_reference_file(refname); + 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)); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_open_filename(a, refname, 10240)); + + /* Verify regular file but with encrypted headers + as a consequence, all meta information is invalid. */ + assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae)); + + assertEqualInt(0, archive_entry_mode(ae)); + assertEqualString(NULL, archive_entry_pathname(ae)); + assertEqualInt(0, archive_entry_mtime(ae)); + assertEqualInt(0, archive_entry_size(ae)); + assertEqualInt(1, archive_entry_is_data_encrypted(ae)); + assertEqualInt(1, archive_entry_is_metadata_encrypted(ae)); + assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a)); + assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff))); + + assertEqualInt(1, archive_file_count(a)); + + /* End of archive. */ + assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae)); + + /* Verify archive format. */ + assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0)); + assertEqualIntA(a, ARCHIVE_FORMAT_ZIP, archive_format(a)); + + /* Close the archive. */ + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} diff --git a/libarchive/test/test_read_format_zip_encryption_header.zip.uu b/libarchive/test/test_read_format_zip_encryption_header.zip.uu new file mode 100644 index 000000000..8ba23d322 --- /dev/null +++ b/libarchive/test/test_read_format_zip_encryption_header.zip.uu @@ -0,0 +1,32 @@ +begin 664 test_read_format_zip_encryption_header.zip +M4$L#!#,`02``````````````5@$````````!````,1``X3'*9,%K7_13)[I3 +MUO.*N2`!```#`!!F``$!`)``M'BJYI=VDZMXC4&]B1)Q%WJ/M`8VS +M%S*.0\5[MJ34[W"H8*AO==S@TG'S'J'3A;8C`````(``4-?ZX*L^`*0786KZ +ME7<\#%<[_`^#/MO"P\3FX5`^9`Q%(S:FDO98B*C`BC%'XQ0*X"FMO8[@3'S@ +MX(JO5(Q:8-&AM8(OPBY40\O!"%Z5'>I\/<_(AA-%)*TBI6YT6!WEM7L,-"W( +M/GE:7T.B39$3C.W)X2`A=KV-UB4C7I?6B-!F<"?VLE!+`P0S`$$@`````````````%8!`````````0```#(0 +M`%(U7N:0Z+,VS3SNJBRE_=`@`0```P`09@`!`0"0`+1XJN:7=I'+8EUNW[TZ +M9--K0QS.:Q+!FI.`8[!4$,6L*CF!QS:J1.BO`?`/13>YAU`IT$;$9 +M?;.\]/UPBB3_SV=KT;*]:?(9JYM:X+6&:R4J*4S0N)^KE,\XI>AO)H,GWNK> +M(U!O8D2<1=ZC[0&-LQ[:DU.]PJ&"H;W7CYF;:)G.8S3 +M%AT<])L+^"37+I@-S&ALBA\_10'AM,+6C"RP!FEV@VW1"2PDL->Q5HL*M[X( +M];^?-43F%4=UMP/U>83:C4K&OM*'&=DS[_V!*YK9X(6G9R,]GJ\\0`!A&@I%F4R!H=;RQSVWL,/D@ +M`0```P`09@`!`0"0`+1XJN:7=I'+8EUNW[TZ9--K0QS.:Q+!FI.`8[!4$,6L +M*CF!QS:J1.BO`?`/13>YAU`IT$;$9?;.\]/UPBB3_SV=KT;*]:?(9 +MJYM:X+6&:R4J*4S0N)^KE,\XI>AO)H,GWNK>(U!O8D2<1=ZC[0&-LQ[:DU.]PJ&"H;W7A2^EL1N!T3'%DP<< +MXY=DJB$8LS8KERBNN[I*X]M"?A\FYX"B`IP_XMQ-.*H3#`XY.,-K% +M0`Z%4:U*W#IM_DBOP-$^?R<8,!%#Z6F1`?;Z:=LG6@'C+#0I[]^+E$0'L5!+ +M!@9,`````````$``/@```````````````````````@````````"F`0`````` +M`.H"````````"`"F`0```````-(`````````$&8``0$``0`$``"$P.)02P8' +F`````)`$`````````0```%!+!08```````#__Z8!``#J`@`````` +` +end diff --git a/libarchive/test/test_read_format_zip_encryption_partially.c b/libarchive/test/test_read_format_zip_encryption_partially.c new file mode 100644 index 000000000..330497a8c --- /dev/null +++ b/libarchive/test/test_read_format_zip_encryption_partially.c @@ -0,0 +1,79 @@ +/*- + * Copyright (c) 2013 Konrad Kleine + * 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$"); + +DEFINE_TEST(test_read_format_zip_encryption_partially) +{ + /* This file contains one file that is encrypted (foo.txt, password=12345678) + and one file that is not encrypted (bar.txt) The header is not encrypted + on this file. */ + const char *refname = "test_read_format_zip_encryption_partially.zip"; + struct archive_entry *ae; + struct archive *a; + char buff[128]; + + extract_reference_file(refname); + 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)); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_open_filename(a, refname, 10240)); + + /* Verify unencrypted file "bar.txt". */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt((AE_IFREG | 0666), archive_entry_mode(ae)); + assertEqualString("bar.txt", archive_entry_pathname(ae)); + assertEqualInt(1379416406, archive_entry_mtime(ae)); + assertEqualInt(20, archive_entry_size(ae)); + assertEqualInt(0, archive_entry_is_data_encrypted(ae)); + assertEqualInt(0, archive_entry_is_metadata_encrypted(ae)); + assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a)); + assertEqualInt(20, archive_read_data(a, buff, sizeof(buff))); + + /* Verify encrypted file "foo.txt". */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt((AE_IFREG | 0666), archive_entry_mode(ae)); + assertEqualString("foo.txt", archive_entry_pathname(ae)); + assertEqualInt(1379416400, archive_entry_mtime(ae)); + assertEqualInt(20, archive_entry_size(ae)); + assertEqualInt(1, archive_entry_is_data_encrypted(ae)); + assertEqualInt(0, archive_entry_is_metadata_encrypted(ae)); + assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a)); + assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, sizeof(buff))); + + assertEqualInt(2, archive_file_count(a)); + + /* End of archive. */ + assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + + /* Verify archive format. */ + assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0)); + assertEqualIntA(a, ARCHIVE_FORMAT_ZIP, archive_format(a)); + + /* Close the archive. */ + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} diff --git a/libarchive/test/test_read_format_zip_encryption_partially.zip.uu b/libarchive/test/test_read_format_zip_encryption_partially.zip.uu new file mode 100644 index 000000000..ac19d3133 --- /dev/null +++ b/libarchive/test/test_read_format_zip_encryption_partially.zip.uu @@ -0,0 +1,18 @@ +begin 664 test_read_format_zip_encryption_partially.zip +M4$L#!`H``````*UI,4/H*IFA%````!0````'````8F%R+G1X=")D871A(&]F +M(&)A'0B(`T*4$L#!#,`00```*II,4/_S`925@$``!0````'````9F]O +M+G1X=!``=Y31BJ>9'GG$*/<^F6_&OGLZO5E%/W5NJ591,`8BB:/5/7M)AK8/IJ0=@ +M`````(``QS1<"+$&V4,T_.3PQ&HBEXWEA;,\K(U'9+L4P +M=:(P%7DH*U7(2#M.IB;M\7X??Y!F]%PMN<#((2`+)9A+<(W[1K0X@&5:`QJV +MQ:NR:QT5U'+D!K^/_N*M>SJ-)-^@^N6]4VD&Z@L#X(!-7@-6#-G3WV`1:PL" +M!4FWNU]+#`:$,2UI5U`@#@BY.)#$HP6(2