From 0d9cd9e9cf39e1cdb06565de6c4e11ff244b2a3a Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Tue, 5 May 2015 15:58:27 -0700 Subject: [PATCH] DO NOT MERGE Fix problem that reading/writing crypto footers wasn't identity (cherry-picked from commit 75c922f49b593f3203ee59c33d00ccb5b3b66ca8) Bug: 18151196 Change-Id: Ideef6bcdbccf068a64ed3e042be50c4837a373f8 --- Ext4Crypt.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Ext4Crypt.cpp b/Ext4Crypt.cpp index 150014c..dcdcd62 100644 --- a/Ext4Crypt.cpp +++ b/Ext4Crypt.cpp @@ -105,6 +105,7 @@ static int get_crypt_ftr_and_key(crypt_mnt_ftr& crypt_ftr, crypt_ftr.magic = props.Get(tag::magic); crypt_ftr.major_version = props.Get(tag::major_version); crypt_ftr.minor_version = props.Get(tag::minor_version); + crypt_ftr.ftr_size = sizeof(crypt_ftr); crypt_ftr.flags = props.Get(tag::flags); crypt_ftr.crypt_type = props.Get(tag::crypt_type); crypt_ftr.failed_decrypt_count = props.Get(tag::failed_decrypt_count); @@ -187,6 +188,11 @@ int e4crypt_enable(const char* path) 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)) { SLOGE("Failed to write crypto footer"); return -1; @@ -200,8 +206,7 @@ int e4crypt_enable(const char* path) if (memcmp(&ftr, &ftr2, sizeof(ftr)) != 0) { SLOGE("Crypto footer not correctly written"); - // ex4enc:TODO why is this failing? - //return -1; + return -1; } }