From ddb63e27f2cdba7ab3757abdc12a34cc02095345 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Thu, 19 Jan 2017 14:01:57 -0600 Subject: Timeout for decrypt Sometimes, usually because of proprietary binaries related to keymaster, decrypt will hang waiting for the keymaster to initialize forever. This patch enables a timeout so that we don't get stuck trying to decrypt forever. A timeout is especially important when dealing with the default password because the user has no option to cancel when TWRP tries to decrypt. NOTE: This patch only adds a timeout for FDE. FBE will require some special handling because we need access to some static data and that data is not available across a fork. Special thanks to nkk71 for cleaning up some issues in my patch set. Change-Id: Iccf2fe769ac27a7dcd6bfebfe7d2e9eddd034308 --- twrp-functions.hpp | 1 + 1 file changed, 1 insertion(+) (limited to 'twrp-functions.hpp') diff --git a/twrp-functions.hpp b/twrp-functions.hpp index ebbe99d10..82a4c1b08 100644 --- a/twrp-functions.hpp +++ b/twrp-functions.hpp @@ -52,6 +52,7 @@ public: static int Exec_Cmd(const string& cmd, string &result); //execute a command and return the result as a string by reference static int Exec_Cmd(const string& cmd); //execute a command static int Wait_For_Child(pid_t pid, int *status, string Child_Name); // Waits for pid to exit and checks exit status + static int Wait_For_Child_Timeout(pid_t pid, int *status, const string& Child_Name, int timeout); // Waits for a pid to exit until the timeout is hit. If timeout is hit, kill the chilld. static bool Path_Exists(string Path); // Returns true if the path exists static Archive_Type Get_File_Type(string fn); // Determines file type, 0 for unknown, 1 for gzip, 2 for OAES encrypted static int Try_Decrypting_File(string fn, string password); // -1 for some error, 0 for failed to decrypt, 1 for decrypted, 3 for decrypted and found gzip format -- cgit v1.2.3