diff options
author | Ethan Yonker <dees_troy@teamw.in> | 2017-01-19 21:01:57 +0100 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2017-03-01 22:56:47 +0100 |
commit | ddb63e27f2cdba7ab3757abdc12a34cc02095345 (patch) | |
tree | bec2a6f8f18ee1f77ad568c8da76cc419b5ff7ca /partitionmanager.cpp | |
parent | gui: preserve order of gui_print vs gui_msg (diff) | |
download | android_bootable_recovery-ddb63e27f2cdba7ab3757abdc12a34cc02095345.tar android_bootable_recovery-ddb63e27f2cdba7ab3757abdc12a34cc02095345.tar.gz android_bootable_recovery-ddb63e27f2cdba7ab3757abdc12a34cc02095345.tar.bz2 android_bootable_recovery-ddb63e27f2cdba7ab3757abdc12a34cc02095345.tar.lz android_bootable_recovery-ddb63e27f2cdba7ab3757abdc12a34cc02095345.tar.xz android_bootable_recovery-ddb63e27f2cdba7ab3757abdc12a34cc02095345.tar.zst android_bootable_recovery-ddb63e27f2cdba7ab3757abdc12a34cc02095345.zip |
Diffstat (limited to 'partitionmanager.cpp')
-rw-r--r-- | partitionmanager.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 908730e57..c1b857ca9 100644 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -1513,7 +1513,7 @@ void TWPartitionManager::Post_Decrypt(const string& Block_Device) { int TWPartitionManager::Decrypt_Device(string Password) { #ifdef TW_INCLUDE_CRYPTO - char crypto_state[PROPERTY_VALUE_MAX], crypto_blkdev[PROPERTY_VALUE_MAX], cPassword[255]; + char crypto_state[PROPERTY_VALUE_MAX], crypto_blkdev[PROPERTY_VALUE_MAX]; std::vector<TWPartition*>::iterator iter; // Mount any partitions that need to be mounted for decrypt @@ -1549,8 +1549,25 @@ int TWPartitionManager::Decrypt_Device(string Password) { return -1; } - strcpy(cPassword, Password.c_str()); - int pwret = cryptfs_check_passwd(cPassword); + int pwret = -1; + pid_t pid = fork(); + if (pid < 0) { + LOGERR("fork failed\n"); + return -1; + } else if (pid == 0) { + // Child process + char cPassword[255]; + strcpy(cPassword, Password.c_str()); + int ret = cryptfs_check_passwd(cPassword); + exit(ret); + } else { + // Parent + int status; + if (TWFunc::Wait_For_Child_Timeout(pid, &status, "Decrypt", 30)) + pwret = -1; + else + pwret = WEXITSTATUS(status) ? -1 : 0; + } // Unmount any partitions that were needed for decrypt for (iter = Partitions.begin(); iter != Partitions.end(); iter++) { |