From: Konrad Kleine Date: Wed, 18 Sep 2013 08:27:21 +0000 (+0200) Subject: Store encryption info in single char of entry X-Git-Tag: v3.1.900a~347^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fec2ae3cd3b16ae97a8bf3ff2c8b878697e9852e;p=thirdparty%2Flibarchive.git Store encryption info in single char of entry Instead of two chars the information about encryption is now stored in one single char inside of an archive_entry struct. --- diff --git a/libarchive/archive_entry.c b/libarchive/archive_entry.c index 101e61f1e..27f79ecae 100644 --- a/libarchive/archive_entry.c +++ b/libarchive/archive_entry.c @@ -202,8 +202,7 @@ archive_entry_clone(struct archive_entry *entry) 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; + entry2->encryption = entry->encryption; /* Copy ACL data over. */ archive_acl_copy(&entry2->acl, &entry->acl); @@ -702,20 +701,19 @@ _archive_entry_uname_l(struct archive_entry *entry, int archive_entry_is_data_encrypted(struct archive_entry *entry) { - return (entry && entry->is_data_encrypted); + return (entry && (entry->encryption & AE_ENCRYPTION_DATA) == AE_ENCRYPTION_DATA); } int archive_entry_is_metadata_encrypted(struct archive_entry *entry) { - return (entry && entry->is_metadata_encrypted); + return (entry && (entry->encryption & AE_ENCRYPTION_METADATA) == AE_ENCRYPTION_METADATA); } int archive_entry_is_encrypted(struct archive_entry *entry) { - return (entry && (entry->is_data_encrypted - || entry->is_metadata_encrypted)); + return (entry && entry->encryption & (AE_ENCRYPTION_DATA|AE_ENCRYPTION_METADATA)); } /* @@ -1240,18 +1238,26 @@ archive_entry_update_uname_utf8(struct archive_entry *entry, const char *name) } void -archive_entry_set_is_data_encrypted(struct archive_entry *entry, char encrypted) +archive_entry_set_is_data_encrypted(struct archive_entry *entry, char is_encrypted) { if (entry) { - entry->is_data_encrypted = encrypted; + if (is_encrypted) { + entry->encryption |= AE_ENCRYPTION_DATA; + } else { + entry->encryption &= ~AE_ENCRYPTION_DATA; + } } } void -archive_entry_set_is_metadata_encrypted(struct archive_entry *entry, char encrypted) +archive_entry_set_is_metadata_encrypted(struct archive_entry *entry, char is_encrypted) { - if (entry) { - entry->is_metadata_encrypted = encrypted; + if (entry) { + if (is_encrypted) { + entry->encryption |= AE_ENCRYPTION_METADATA; + } else { + entry->encryption &= ~AE_ENCRYPTION_METADATA; + } } } diff --git a/libarchive/archive_entry_private.h b/libarchive/archive_entry_private.h index 74b50da6b..c69233e68 100644 --- a/libarchive/archive_entry_private.h +++ b/libarchive/archive_entry_private.h @@ -154,8 +154,10 @@ struct archive_entry { /* Not used within libarchive; useful for some clients. */ struct archive_mstring ae_sourcepath; /* Path this entry is sourced from. */ - char is_data_encrypted; - char is_metadata_encrypted; +#define AE_ENCRYPTION_NONE 0 +#define AE_ENCRYPTION_DATA 1 +#define AE_ENCRYPTION_METADATA 2 + char encryption; void *mac_metadata; size_t mac_metadata_size;