From 5da130284e3f0f4a7d3422bfec4db9ce551ecc78 Mon Sep 17 00:00:00 2001 From: Gordon Freeman Date: Sun, 10 Apr 2016 18:35:25 +0200 Subject: Partition: Fix parsing of several twrp fstab flags fix parsing when using storagename=, backupname= and userdataencryptbackup= in twrp.fstab also split encryptable= and forceencrypt= into seperate blocks and make storage=Y working Change-Id: I674f7ffe7f9e4ff121c4dccf79096360e044535c --- partition.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'partition.cpp') diff --git a/partition.cpp b/partition.cpp index 12d4ad0da..4f66c5f1a 100644 --- a/partition.cpp +++ b/partition.cpp @@ -486,7 +486,7 @@ bool TWPartition::Process_Flags(string Flags, bool Display_Error) { if (ptr_len == 7) { Is_Storage = true; } else if (ptr_len == 9) { - ptr += 9; + ptr += 8; if (*ptr == '1' || *ptr == 'y' || *ptr == 'Y') { LOGINFO("storage set to true\n"); Is_Storage = true; @@ -536,17 +536,17 @@ bool TWPartition::Process_Flags(string Flags, bool Display_Error) { if (Display_Name.substr(Display_Name.size() - 1, 1) == "\"") { Display_Name.resize(Display_Name.size() - 1); } - } else if (ptr_len > 11 && strncmp(ptr, "storagename=", 11) == 0) { + } else if (ptr_len > 12 && strncmp(ptr, "storagename=", 12) == 0) { has_storage_name = true; - ptr += 11; + ptr += 12; if (*ptr == '\"') ptr++; Storage_Name = ptr; if (Storage_Name.substr(Storage_Name.size() - 1, 1) == "\"") { Storage_Name.resize(Storage_Name.size() - 1); } - } else if (ptr_len > 11 && strncmp(ptr, "backupname=", 10) == 0) { + } else if (ptr_len > 11 && strncmp(ptr, "backupname=", 11) == 0) { has_backup_name = true; - ptr += 10; + ptr += 11; if (*ptr == '\"') ptr++; Backup_Display_Name = ptr; if (Backup_Display_Name.substr(Backup_Display_Name.size() - 1, 1) == "\"") { @@ -564,8 +564,8 @@ bool TWPartition::Process_Flags(string Flags, bool Display_Error) { Can_Encrypt_Backup = true; else Can_Encrypt_Backup = false; - } else if (ptr_len > 21 && strncmp(ptr, "userdataencryptbackup=", 21) == 0) { - ptr += 21; + } else if (ptr_len > 22 && strncmp(ptr, "userdataencryptbackup=", 22) == 0) { + ptr += 22; if (*ptr == '1' || *ptr == 'y' || *ptr == 'Y') { Can_Encrypt_Backup = true; Use_Userdata_Encryption = true; @@ -581,11 +581,16 @@ bool TWPartition::Process_Flags(string Flags, bool Display_Error) { Mount_Options.resize(Mount_Options.size() - 1); } Process_FS_Flags(Mount_Options, Mount_Flags); - } else if ((ptr_len > 12 && strncmp(ptr, "encryptable=", 12) == 0) || (ptr_len > 13 && strncmp(ptr, "forceencrypt=", 13) == 0)) { + } else if (ptr_len > 12 && strncmp(ptr, "encryptable=", 12) == 0) { ptr += 12; - if (*ptr == '=') ptr++; if (*ptr == '\"') ptr++; - + Crypto_Key_Location = ptr; + if (Crypto_Key_Location.substr(Crypto_Key_Location.size() - 1, 1) == "\"") { + Crypto_Key_Location.resize(Crypto_Key_Location.size() - 1); + } + } else if (ptr_len > 13 && strncmp(ptr, "forceencrypt=", 13) == 0) { + ptr += 13; + if (*ptr == '\"') ptr++; Crypto_Key_Location = ptr; if (Crypto_Key_Location.substr(Crypto_Key_Location.size() - 1, 1) == "\"") { Crypto_Key_Location.resize(Crypto_Key_Location.size() - 1); -- cgit v1.2.3