diff options
-rw-r--r-- | partitionmanager.cpp | 6 | ||||
-rw-r--r-- | twrp-functions.cpp | 7 |
2 files changed, 8 insertions, 5 deletions
diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 67ec84ec5..2bcbc2713 100644 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -61,8 +61,12 @@ int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error) if (fstab_line[0] != '/') continue; + if (fstab_line[strlen(fstab_line) - 1] != '\n') + fstab_line[strlen(fstab_line)] = '\n'; + TWPartition* partition = new TWPartition(); - string line(fstab_line); + string line = fstab_line; + if (partition->Process_Fstab_Line(line, Display_Error)) { Partitions.push_back(partition); } else { diff --git a/twrp-functions.cpp b/twrp-functions.cpp index 90c60165e..0b2258a90 100644 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -25,11 +25,10 @@ int TWFunc::Check_MD5(string File) { size_t pos; MD5_File = File + ".md5"; - if (access(MD5_File.c_str(), F_OK ) != -1) { + if (Path_Exists(MD5_File)) { DirPath = Get_Path(File); - chdir(DirPath.c_str()); MD5_File = Get_Filename(MD5_File); - Command = "/sbin/busybox md5sum -c '" + MD5_File + "' > /tmp/md5output"; + Command = "cd '" + DirPath + "' && /sbin/busybox md5sum -c '" + MD5_File + "' > /tmp/md5output"; system(Command.c_str()); FILE * cs = fopen("/tmp/md5output", "r"); if (cs == NULL) { @@ -38,6 +37,7 @@ int TWFunc::Check_MD5(string File) { } fgets(line, sizeof(line), cs); + fclose(cs); Sline = line; pos = Sline.find(":"); @@ -56,7 +56,6 @@ int TWFunc::Check_MD5(string File) { // MD5 is bad, return 0 ret = 0; } - fclose(cs); } else { //No md5 file, return -1 ret = -1; |