diff options
author | big biff <bigbiff@teamw.in> | 2016-11-08 00:54:28 +0100 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit> | 2016-11-08 00:54:28 +0100 |
commit | bb0da94f40d8fe7779deea78e3ad2c1eeb1c4180 (patch) | |
tree | f4f929e0da5f6ee51f7d4a442b6165394f242edd /twrpDigest.cpp | |
parent | Fix image flashing: attempt 2 (diff) | |
parent | MD5 verification sanity (diff) | |
download | android_bootable_recovery-bb0da94f40d8fe7779deea78e3ad2c1eeb1c4180.tar android_bootable_recovery-bb0da94f40d8fe7779deea78e3ad2c1eeb1c4180.tar.gz android_bootable_recovery-bb0da94f40d8fe7779deea78e3ad2c1eeb1c4180.tar.bz2 android_bootable_recovery-bb0da94f40d8fe7779deea78e3ad2c1eeb1c4180.tar.lz android_bootable_recovery-bb0da94f40d8fe7779deea78e3ad2c1eeb1c4180.tar.xz android_bootable_recovery-bb0da94f40d8fe7779deea78e3ad2c1eeb1c4180.tar.zst android_bootable_recovery-bb0da94f40d8fe7779deea78e3ad2c1eeb1c4180.zip |
Diffstat (limited to 'twrpDigest.cpp')
-rw-r--r-- | twrpDigest.cpp | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/twrpDigest.cpp b/twrpDigest.cpp index ab8f456f5..d1217cb6a 100644 --- a/twrpDigest.cpp +++ b/twrpDigest.cpp @@ -91,7 +91,7 @@ int twrpDigest::computeMD5(void) { initMD5(); file = fopen(md5fn.c_str(), "rb"); if (file == NULL) - return -1; + return MD5_NOT_FOUND; while ((len = fread(buf, 1, sizeof(buf), file)) > 0) { MD5Update(&md5c, buf, len); } @@ -128,24 +128,14 @@ int twrpDigest::read_md5digest(void) { i++; } - if (!foundMd5File) { - gui_msg("no_md5=Skipping MD5 check: no MD5 file found"); - return -1; - } else if (TWFunc::read_file(md5file, line) != 0) { - LOGERR("Skipping MD5 check: MD5 file unreadable %s\n", strerror(errno)); - return 1; - } + if (!foundMd5File) + return MD5_NOT_FOUND; + if (TWFunc::read_file(md5file, line) != 0) + return MD5_FILE_UNREADABLE; 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]; @@ -164,11 +154,8 @@ int twrpDigest::verify_md5digest(void) { snprintf(hex, 3, "%02x", md5sum[i]); md5str += hex; } - if (tokens.at(0) != md5str) { - gui_err("md5_fail=MD5 does not match"); - return -2; - } + if (tokens.at(0) != md5str) + return MD5_MATCH_FAIL; - gui_msg("md5_match=MD5 matched"); - return 0; + return MD5_OK; } |