summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Mower <mowerm@gmail.com>2014-04-15 19:50:58 +0200
committerGerrit Code Review <gerrit2@gerrit>2014-04-16 21:46:53 +0200
commitd5c1a9220ddcdc1b849cf5f58e7054ea7a227824 (patch)
treeab3af14270b3594885071d773fe6dc78899cf32f
parentMake blank timer read brightness path from data manager (diff)
downloadandroid_bootable_recovery-d5c1a9220ddcdc1b849cf5f58e7054ea7a227824.tar
android_bootable_recovery-d5c1a9220ddcdc1b849cf5f58e7054ea7a227824.tar.gz
android_bootable_recovery-d5c1a9220ddcdc1b849cf5f58e7054ea7a227824.tar.bz2
android_bootable_recovery-d5c1a9220ddcdc1b849cf5f58e7054ea7a227824.tar.lz
android_bootable_recovery-d5c1a9220ddcdc1b849cf5f58e7054ea7a227824.tar.xz
android_bootable_recovery-d5c1a9220ddcdc1b849cf5f58e7054ea7a227824.tar.zst
android_bootable_recovery-d5c1a9220ddcdc1b849cf5f58e7054ea7a227824.zip
-rw-r--r--twinstall.cpp10
-rw-r--r--twrpDigest.cpp26
2 files changed, 24 insertions, 12 deletions
diff --git a/twinstall.cpp b/twinstall.cpp
index d95efed13..4247cf7d8 100644
--- a/twinstall.cpp
+++ b/twinstall.cpp
@@ -260,14 +260,10 @@ extern "C" int TWinstall_zip(const char* path, int* wipe_cache) {
gui_print("Installing '%s'...\nChecking for MD5 file...\n", path);
md5sum.setfn(strpath);
md5_return = md5sum.verify_md5digest();
- if (md5_return == -2) {
- // MD5 did not match.
- LOGERR("Zip MD5 does not match.\nUnable to install zip.\n");
+ if (md5_return == -2) { // md5 did not match
+ LOGERR("Aborting zip install\n");
return INSTALL_CORRUPT;
- } else if (md5_return == -1) {
- gui_print("Skipping MD5 check: no MD5 file found.\n");
- } else if (md5_return == 0)
- gui_print("Zip MD5 matched.\n"); // MD5 found and matched.
+ }
#ifndef TW_OEM_BUILD
DataManager::GetValue(TW_SIGNED_ZIP_VERIFY_VAR, zip_verify);
diff --git a/twrpDigest.cpp b/twrpDigest.cpp
index 6726df3e5..0693c5500 100644
--- a/twrpDigest.cpp
+++ b/twrpDigest.cpp
@@ -19,6 +19,7 @@
extern "C"
{
#include "digest/md5.h"
+ #include "gui/gui.h"
#include "libcrecovery/common.h"
}
@@ -100,21 +101,32 @@ int twrpDigest::read_md5digest(void) {
}
if (!foundMd5File) {
+ gui_print("Skipping MD5 check: no MD5 file found\n");
return -1;
} else if (TWFunc::read_file(md5file, line) != 0) {
- LOGERR("Could not read %s\n", md5file.c_str());
+ gui_print("Skipping MD5 check: MD5 file unreadable\n");
+ return 1;
}
return 0;
}
+/* verify_md5digest return codes:
+ -2: md5 did not match
+ -1: no md5 file found
+ 0: md5 matches
+ 1: md5 file unreadable
+*/
+
int twrpDigest::verify_md5digest(void) {
string buf;
char hex[3];
- int i;
+ int i, ret;
string md5string;
- if (read_md5digest() != 0)
- return -1;
+
+ ret = read_md5digest();
+ if (ret != 0)
+ return ret;
stringstream ss(line);
vector<string> tokens;
while (ss >> buf)
@@ -124,7 +136,11 @@ int twrpDigest::verify_md5digest(void) {
snprintf(hex, 3, "%02x", md5sum[i]);
md5string += hex;
}
- if (tokens.at(0) != md5string)
+ if (tokens.at(0) != md5string) {
+ LOGERR("MD5 does not match\n");
return -2;
+ }
+
+ gui_print("MD5 matched\n");
return 0;
}