Merge "Fix error in clocks leading to devices staying unlocked" into lmp-mr1-dev
diff --git a/CommandListener.cpp b/CommandListener.cpp
index 4c65959..f135a01 100644
--- a/CommandListener.cpp
+++ b/CommandListener.cpp
@@ -710,8 +710,14 @@
dumpArgs(argc, argv, -1);
char* password = cryptfs_get_password();
if (password) {
- cli->sendMsg(ResponseCode::CommandOkay, password, false);
- return 0;
+ char* message = 0;
+ int size = asprintf(&message, "{{sensitive}} %s", password);
+ if (size != -1) {
+ cli->sendMsg(ResponseCode::CommandOkay, message, false);
+ memset(message, 0, size);
+ free (message);
+ return 0;
+ }
}
rc = -1;
} else if (!strcmp(argv[1], "clearpw")) {
diff --git a/cryptfs.c b/cryptfs.c
index 2a6586b..a424b69 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -3186,7 +3186,8 @@
}
/* Calculate checksum if we are not finished */
- if (!rc && crypt_ftr.encrypted_upto != crypt_ftr.fs_size) {
+ if (!rc && how == CRYPTO_ENABLE_INPLACE
+ && crypt_ftr.encrypted_upto != crypt_ftr.fs_size) {
rc = cryptfs_SHA256_fileblock(crypto_blkdev,
crypt_ftr.hash_first_block);
if (rc) {
@@ -3204,7 +3205,8 @@
/* Success */
crypt_ftr.flags &= ~CRYPT_INCONSISTENT_STATE;
- if (crypt_ftr.encrypted_upto != crypt_ftr.fs_size) {
+ if (how == CRYPTO_ENABLE_INPLACE
+ && crypt_ftr.encrypted_upto != crypt_ftr.fs_size) {
SLOGD("Encrypted up to sector %lld - will continue after reboot",
crypt_ftr.encrypted_upto);
crypt_ftr.flags |= CRYPT_ENCRYPTION_IN_PROGRESS;
@@ -3212,7 +3214,8 @@
put_crypt_ftr_and_key(&crypt_ftr);
- if (crypt_ftr.encrypted_upto == crypt_ftr.fs_size) {
+ if (how == CRYPTO_ENABLE_WIPE
+ || crypt_ftr.encrypted_upto == crypt_ftr.fs_size) {
char value[PROPERTY_VALUE_MAX];
property_get("ro.crypto.state", value, "");
if (!strcmp(value, "")) {