#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.
*/
__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);
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);
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.
*/
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)
__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.
__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
/* 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;
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
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;
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);
}
}
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. */
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);
#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
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 *,
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)
{
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)
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 && fidx<folder->numCoders; 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,
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);
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) {
* 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),
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);
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);
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);
archive_read_format_empty_read_data,
NULL,
NULL,
+ NULL,
+ NULL,
NULL);
return (r);
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);
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);
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);
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 *);
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)
{
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);
}
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)
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);
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);
xar_read_data,
xar_read_data_skip,
NULL,
- xar_cleanup);
+ xar_cleanup,
+ NULL,
+ NULL);
if (r != ARCHIVE_OK)
free(xar);
return (r);
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;
};
#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 *,
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);
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)
{
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)
__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;
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);
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. */
__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
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
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);
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);
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);
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);
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
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
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
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);
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));
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);
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);
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);
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);
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);
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));
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));
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));
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));
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);
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));
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);
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);
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);
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);
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);
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);
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);
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);
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));
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))
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))
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))
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);
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));
--- /dev/null
+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<!"E,'V61M9)J_#M4C`P$!!5T```$``0`,
+M"`0`"`H!J&4R?@``!0$1$0!B`&$`<@`N`'0`>`!T````%`H!``"&-JAYL,X!
+*%08!`""`M($`````
+`
+end
--- /dev/null
+/*-
+ * 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));
+}
+
--- /dev/null
+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%<HF+_9E78TWJ!
+M5Q=ZF(.88]0Y3<U4PI>*%S+LERGW+.D%XK*'>5.FQ>74JN]"%`5%TTQ[@L^#
+MZVV`LJT"<VY^#I<U<O#)7:DEX*#)1,]DQA<&$`$)<``'"P$``20&\0<!"E,'
+23QKRY44=+M(,80H!^V/0)@``
+`
+end
--- /dev/null
+/*-
+ * 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_header)
+{
+ /* This file is password protected (encrypted) with AES-256. The headers
+ ARE encrypted. Password is "12345678". */
+ const char *refname = "test_read_format_7zip_encryption_header.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 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_7ZIP, archive_format(a));
+
+ /* Close the archive. */
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
--- /dev/null
+begin 664 test_read_format_7zip_encryption_partially.7z
+M-WJ\KR<<``-.Y/D@G``````````B`````````)D0(6<`,QOL%````&2Q`&1E
+M$MIXH*@X+XD>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
--- /dev/null
+/*-
+ * 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));
+}
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));
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));
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));
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.
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));
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);
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);
/* 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));
/* 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));
"\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));
"\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. */
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));
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. */
*/
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);
/*
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));
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));
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));
}
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);
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));
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));
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));
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));
}
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));
}
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, 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));
}
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));
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));
}
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));
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));
}
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));
}
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. */
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));
}
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));
}
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,
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));
}
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));
}
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), "");
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));
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));
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). */
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));
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';
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). */
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). */
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));
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));
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). */
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). */
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));
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));
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
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));
* 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. */
* 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. */
* 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. */
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));
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));
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));
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. */
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));
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. */
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));
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) {
} 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));
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));
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");
/* 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));
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));
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));
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));
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));
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__)
#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));
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));
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));
}
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));
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));
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));
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));
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));
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));
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));
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));
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 */
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 */
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));
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);
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));
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));
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 */
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 */
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);
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));
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);
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);
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));
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));
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)));
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);
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));
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);
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);
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));
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));
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)));
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);
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);
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);
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);
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. */
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));
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));
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)));
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);
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));
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);
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);
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));
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));
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));
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));
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. */
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));
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));
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));
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));
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);
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. */
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);
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));
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));
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);
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));
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) ==
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));
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));
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);
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);
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);
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);
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);
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);
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)));
/*
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)));
/*
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)));
/*
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)));
/*
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)));
/*
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)));
/*
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.
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.
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.
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));
--- /dev/null
+/*-
+ * 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));
+}
+
--- /dev/null
+begin 664 test_read_format_rar_encryption_data.rar
+M4F%R(1H'`,^0<P``#0````````!=_'0DA"\`(````!`````#7(:MIJ5,,4,=
+M,P<`M($``&9O;RYT>'1/`[S9UA9,WT5`&I*2B-\5*XZ>SW"Y0.C)1^;.UK]$
+MXK@UJ)SH93<!!T5T)(0O`"`````0`````[[BD,VF3#%#'3,'`+2!``!B87(N
+M='AT3P.\V=863-]P='I(B8@/9EM]Y0:Y<AZH)57XRC<!H^WT\13S(V31H<0]
+%>P!`!P``
+`
+end
--- /dev/null
+/*-
+ * 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));
+}
--- /dev/null
+begin 664 test_read_format_rar_encryption_header.rar
+M4F%R(1H'`,Z9<X``#0````````#C+JMDIUQVC(1'0@#+RLR?%V>1EQMQ=@1S
+M,[$:0Y\;'G8_C0D%2L":*;.B*LM0!,!.2!RBU?+`DTN9KXD\<4RGSC<K5.$U
+M5ZP^2+6",C4`Q^N*MW0)<$U,XRZK9*=<=HRJEM_P8GIN:*4ZDP<>+#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
--- /dev/null
+/*-
+ * 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));
+}
--- /dev/null
+begin 664 test_read_format_rar_encryption_partially.rar
+M4F%R(1H'`,^0<P``#0````````"7.G0DA"\`(````!`````#7(:MIJ5,,4,=
+M,P<`M($``&9O;RYT>'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
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);
/* 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));
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));
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);
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));
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));
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. */
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.
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. */
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));
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));
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.
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. */
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.
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. */
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));
}
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));
}
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));
}
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));
}
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));
}
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));
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));
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. */
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. */
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. */
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. */
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. */
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. */
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. */
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) {
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);
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));
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));
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");
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));
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));
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)
--- /dev/null
+/*-
+ * 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));
+}
+
--- /dev/null
+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^_<G4LZ9N0-"3T
+M?USM"E4Q6?[!.3S$^RX>V7R?(/NINR^)*Z@-<WE<\6H)%,>`+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<JN'$\SDV">
+M?4B:)(8&4)C/_^4!TF+`7W`%52=)VJ9U?3H,W@"9S8062TGSY_<:.\=X_SCC
+M<D],6[)[W+M>1?,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<JIJ)9,DL4<)ZS:,$M6,@`0```P`09@`!`0"0`.\[
+M#ZFPPBZM@S>/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$"<T.,(68%F[9I1ZTS]>;H2&[
+ML$PNS#NDG9Q@BFL$`&S?<RKIF$0-.V![PIJ.+"5GW)3L;JWCD>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
--- /dev/null
+/*-
+ * 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));
+}
--- /dev/null
+begin 664 test_read_format_zip_encryption_header.zip
+M4$L#!#,`02``````````````5@$````````!````,1``X3'*9,%K7_13)[I3
+MUO.*N2`!```#`!!F``$!`)``M'BJYI=VD<MB76[?O3IDTVM#',YK$L&:DX!C
+ML%00Q:QRCM/8%XJ.8''-JI$Z*\!\`]%-[F'4"G01L1E]L[ST_7"*)/_/9VO1
+MLKUI\AFKFUK@M89K)2HI3-"XGZN4SSBEZ&\F@R?>ZMXC4&]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-UB4C7<C^OV&:"B?Y]DU=W2*(SFV=8Q]D\Q*W
+M%B9E>I?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<H[3V!>*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<RCD/%>[:DU.]PJ&"H;W7<X-)Q\QZATX6V(P````"`
+M`&O$^CTH9KN(X?(:`+,T7:PMJ"E"?LTSG9^$P881P?4X"%AG>CYF;:)G.8S3
+M%AT<])L+^"37+I@-S&ALBA\_10'AM,+6C"RP!FEV@VW1"2PDL->Q5HL*M[X(
+M];^?-43F%4=UMP/U>8<DO/W\7,S2S5MSP96Y5"C'I3MST([/-X3(VZQ.XNGM
+M>3: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<H[3V!>*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<RCD/%
+M>[:DU.]PJ&"H;W7<X-)Q\QZATX6V(P````"``(/(E'//(-;AFW-I#4'M.C!+
+MWZ-\VREA15;E6=_G,KY#<1*,3$U0:B#`]\N[&'P`IT9>A2^EL1N!T3'%DP<<
+MXY=DJB$8LS8KERBNN[I*X]M"?A<Q))<H]YV`F<GNWHI#Z].M5&6VM)!B&&/1
+M&15"]OG@91-531!<@R6L;"PIU/R)H]QUVXIM$G9<!+J]4N0\+SL(Q,5?)."!
+MY-^!/U`V$I@O%ZUMU2755&HDUS$*:?33>\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
--- /dev/null
+/*-
+ * 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));
+}
--- /dev/null
+begin 664 test_read_format_zip_encryption_partially.zip
+M4$L#!`H``````*UI,4/H*IFA%````!0````'````8F%R+G1X=")D871A(&]F
+M(&)A<BYT>'0B(`T*4$L#!#,`00```*II,4/_S`925@$``!0````'````9F]O
+M+G1X=!``=<L("9.V+5=*CU"'8S([NR`!```#`!!F``$!`)``!P:=O$!^8J-1
+M-@AD4Y2P=)46_!+9\&&2@AT.;]YT2\]U=17;:L*_:G6/FYR"S@WYW%.=]]$I
+MS2"'F_V9+Y4:]4I%FDN+;.6^6W]S536;D2\QBJ_[R9C.57TI'M?VD82"MHPQ
+MD&P>Y31BJ>9'GG$*/<^F6_&OGLZO5E%/W5NJ591,`8BB:/5/7M)AK8/IJ0=@
+M`````(``QS1<"+$&V4,T_.3PQ&HBEXWEA;,\<!Z8TZ4KQ#:]J=>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<B2@W^UO%!+`0)```H``````*UI
+M,4/H*IFA%````!0````'`"0```````$`(`````````!B87(N='AT"@`@````
+M```!`!@`(Z#$[9:SS@$CH,3MEK/.`2.@Q.V6L\X!4$L!`D``,P!!````JFDQ
+M0__,!E)6`0``%`````<`-````````0`@````.0```&9O;RYT>'0*`"``````
+M``$`&``E(UCIEK/.`24C6.F6L\X!)2-8Z9:SS@$7``P``@`09@`!`0``````
+64$L%!@`````"``(`P@```+0!````````
+`
+end
"\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);
/* Verify regular file. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
"\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);
/* End of archive. */
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);
/* Verify archive format. */
assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
/* Verify regular file. */
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 defined(__APPLE__)
/* Compare NFD string. */
assertEqualUTF8String(
/* Verify regular file. */
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 defined(__APPLE__)
/* Compare NFD string. */
assertEqualUTF8String(
assertEqualString("\xc9\xbd\xa4\xc0\xa4\xe8\x2f",
archive_entry_pathname(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 file. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
"\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);
/* Verify regular file. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
"\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);
/* End of archive. */
archive_entry_pathname(ae));
#endif
assertEqualInt(0, 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));
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);
/* Verify regular file. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
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. */
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. */
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. */
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. */
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. */
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. */
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 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. */
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. */
"\x95\x5c\x82\xbe\x82\xe6\x2f\x88\xea\x97\x97\x95\x5c.txt",
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));
"\x95\x5c\x82\xbe\x82\xe6\x2f\x8a\xbf\x8e\x9a.txt",
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. */
"\x95\x5c\x82\xbe\x82\xe6\x2f",
archive_entry_pathname(ae));
assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(archive_entry_is_encrypted(ae), 0);
+ assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
/* Verify directory file. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
"\x95\x5c\x82\xbe\x82\xe6\x2f\x88\xea\x97\x97\x95\x5c.txt",
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));
"\x95\x5c\x82\xbe\x82\xe6\x2f\x8a\xbf\x8e\x9a.txt",
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. */
assertEqualIntA(a, ARCHIVE_EOF, 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);
/* 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. */
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. */
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. */
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. */
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 second file.
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. */
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\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. */
"Unsupported ZIP compression method (deflation)");
assert(archive_errno(a) != 0);
}
+ assertEqualInt(archive_entry_is_encrypted(ae), 0);
+ assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
assertEqualString("file3", archive_entry_pathname(ae));
assertEqualInt(AE_IFREG | 0644, archive_entry_mode(ae));
failure("Mac metadata should be set");
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));