am eae7fc77: Merge "Fix problem that reading/writing crypto footers wasn\'t identity"

* commit 'eae7fc77b60962c9384b31e0f98d14724731ce88':
  Fix problem that reading/writing crypto footers wasn't identity
This commit is contained in:
Paul Lawrence 2015-05-06 23:47:54 +00:00 committed by Android Git Automerger
commit 855f78c29b

View file

@ -105,6 +105,7 @@ static int get_crypt_ftr_and_key(crypt_mnt_ftr& crypt_ftr,
crypt_ftr.magic = props.Get<int>(tag::magic); crypt_ftr.magic = props.Get<int>(tag::magic);
crypt_ftr.major_version = props.Get<int>(tag::major_version); crypt_ftr.major_version = props.Get<int>(tag::major_version);
crypt_ftr.minor_version = props.Get<int>(tag::minor_version); crypt_ftr.minor_version = props.Get<int>(tag::minor_version);
crypt_ftr.ftr_size = sizeof(crypt_ftr);
crypt_ftr.flags = props.Get<int>(tag::flags); crypt_ftr.flags = props.Get<int>(tag::flags);
crypt_ftr.crypt_type = props.Get<int>(tag::crypt_type); crypt_ftr.crypt_type = props.Get<int>(tag::crypt_type);
crypt_ftr.failed_decrypt_count = props.Get<int>(tag::failed_decrypt_count); crypt_ftr.failed_decrypt_count = props.Get<int>(tag::failed_decrypt_count);
@ -187,6 +188,11 @@ int e4crypt_enable(const char* path)
return -1; return -1;
} }
// Scrub fields not used by ext4enc
ftr.persist_data_offset[0] = 0;
ftr.persist_data_offset[1] = 0;
ftr.persist_data_size = 0;
if (put_crypt_ftr_and_key(ftr, key_props)) { if (put_crypt_ftr_and_key(ftr, key_props)) {
SLOGE("Failed to write crypto footer"); SLOGE("Failed to write crypto footer");
return -1; return -1;
@ -200,8 +206,7 @@ int e4crypt_enable(const char* path)
if (memcmp(&ftr, &ftr2, sizeof(ftr)) != 0) { if (memcmp(&ftr, &ftr2, sizeof(ftr)) != 0) {
SLOGE("Crypto footer not correctly written"); SLOGE("Crypto footer not correctly written");
// ex4enc:TODO why is this failing? return -1;
//return -1;
} }
} }