summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Christopher Adduono <jc@adduono.com>2016-10-25 08:18:32 +0200
committerJames Christopher Adduono <jc@adduono.com>2016-11-05 20:48:43 +0100
commit5c3950716e5c7c6279efd5f3f338d6d22e5215e2 (patch)
treeeac6d63ac558644ba313e73fe5e96134e18361ef
parentFix image flashing (diff)
downloadandroid_bootable_recovery-5c3950716e5c7c6279efd5f3f338d6d22e5215e2.tar
android_bootable_recovery-5c3950716e5c7c6279efd5f3f338d6d22e5215e2.tar.gz
android_bootable_recovery-5c3950716e5c7c6279efd5f3f338d6d22e5215e2.tar.bz2
android_bootable_recovery-5c3950716e5c7c6279efd5f3f338d6d22e5215e2.tar.lz
android_bootable_recovery-5c3950716e5c7c6279efd5f3f338d6d22e5215e2.tar.xz
android_bootable_recovery-5c3950716e5c7c6279efd5f3f338d6d22e5215e2.tar.zst
android_bootable_recovery-5c3950716e5c7c6279efd5f3f338d6d22e5215e2.zip
Diffstat (limited to '')
-rw-r--r--gui/theme/common/languages/cz.xml1
-rw-r--r--gui/theme/common/languages/de.xml1
-rw-r--r--gui/theme/common/languages/el.xml1
-rw-r--r--gui/theme/common/languages/en.xml1
-rw-r--r--gui/theme/common/languages/es.xml1
-rw-r--r--gui/theme/common/languages/fr.xml3
-rw-r--r--gui/theme/common/languages/hu.xml1
-rw-r--r--gui/theme/common/languages/it.xml1
-rw-r--r--gui/theme/common/languages/nl.xml1
-rw-r--r--gui/theme/common/languages/pl.xml1
-rw-r--r--gui/theme/common/languages/pt_BR.xml1
-rw-r--r--gui/theme/common/languages/ru.xml1
-rw-r--r--gui/theme/common/languages/sk.xml1
-rw-r--r--gui/theme/common/languages/sl.xml1
-rw-r--r--gui/theme/extra-languages/languages/ja.xml1
-rw-r--r--gui/theme/extra-languages/languages/zh_CN.xml1
-rw-r--r--gui/theme/extra-languages/languages/zh_TW.xml1
-rw-r--r--partition.cpp58
-rw-r--r--partitions.hpp1
-rw-r--r--twinstall.cpp15
-rw-r--r--twrpDigest.cpp29
-rw-r--r--twrpDigest.hpp8
22 files changed, 74 insertions, 56 deletions
diff --git a/gui/theme/common/languages/cz.xml b/gui/theme/common/languages/cz.xml
index 9d6ade658..83cd0b2cf 100644
--- a/gui/theme/common/languages/cz.xml
+++ b/gui/theme/common/languages/cz.xml
@@ -542,6 +542,7 @@
<string name="unable_resize">Nelze natáhnout {1}.</string>
<string name="no_md5_found">Soubor MD5 se nenašel pro \'{1}\'. Prosím zvolte Vypnout kontrolu MD5 během obnovy.</string>
<string name="md5_fail_match">MD5 neodpovídá souboru \'{1}\'.</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Nelze dešifrovat soubor tar \'{1}\'</string>
<string name="format_data_msg">Měli by jste restartovat recovery aby jste mohli znova používat /data.</string>
<string name="format_data_err">Nelze formátovat pro zrušení šifrování.</string>
diff --git a/gui/theme/common/languages/de.xml b/gui/theme/common/languages/de.xml
index d0946f57b..0fc8fcc38 100644
--- a/gui/theme/common/languages/de.xml
+++ b/gui/theme/common/languages/de.xml
@@ -572,6 +572,7 @@
<string name="unable_resize">Größe von {1} kann nicht geändert werden.</string>
<string name="no_md5_found">Keine MD5-Datei für '{1}' gefunden. Bitte MD5-Prüfung für Wiederherstellung deaktivieren.</string>
<string name="md5_fail_match">MD5-Prüfung für '{1}' fehlgeschlagen.</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">TAR-Datei '{1}' konnte nicht entschlüsselt werden.</string>
<string name="format_data_msg">Ein Neustart von TWRP kann notwendig sein, damit /data wieder verwendet werden kann.</string>
<string name="format_data_err">Formatierung zum Entfernen der Verschlüsselung kann nicht durchgeführt werden.</string>
diff --git a/gui/theme/common/languages/el.xml b/gui/theme/common/languages/el.xml
index 7a939fb61..7ec4d15a7 100644
--- a/gui/theme/common/languages/el.xml
+++ b/gui/theme/common/languages/el.xml
@@ -552,6 +552,7 @@
<string name="unable_resize">Δεν είναι δυνατή η αλλαγή μεγέθους {1}.</string>
<string name="no_md5_found">Δεν βρέθηκε MD5 αρχείο για το '{1}'. Παρακαλώ απεπηλέξτε την επαλήθευση MD5 για επαναφορά.</string>
<string name="md5_fail_match">Το MD5 απέτυχε να ταυτίσει με το '{1}'.</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Αποτυχία αποκρυπτογράφησης του αρχείου tar '{1}'</string>
<string name="format_data_msg">Ίσως χρειαστεί να επανεκκινήσετε στο recovery για να ξαναχρησιμοποιήσετε το /data.</string>
<string name="format_data_err">Αδύνατη η διαμόρφωση για να καταργήσετε την κρυπτογράφηση.</string>
diff --git a/gui/theme/common/languages/en.xml b/gui/theme/common/languages/en.xml
index 0a89083d1..6b05a8613 100644
--- a/gui/theme/common/languages/en.xml
+++ b/gui/theme/common/languages/en.xml
@@ -572,6 +572,7 @@
<string name="unable_resize">Unable to resize {1}.</string>
<string name="no_md5_found">No md5 file found for '{1}'. Please unselect Enable MD5 verification to restore.</string>
<string name="md5_fail_match">MD5 failed to match on '{1}'.</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Failed to decrypt tar file '{1}'</string>
<string name="format_data_msg">You may need to reboot recovery to be able to use /data again.</string>
<string name="format_data_err">Unable to format to remove encryption.</string>
diff --git a/gui/theme/common/languages/es.xml b/gui/theme/common/languages/es.xml
index 0b15108d3..6fd693906 100644
--- a/gui/theme/common/languages/es.xml
+++ b/gui/theme/common/languages/es.xml
@@ -555,6 +555,7 @@
<string name="unable_resize">Incapaz de cambiar el tamaño de archivo de {1}.</string>
<string name="no_md5_found">No se encuentra archivo md5 para \'{1}\'. Por favor, deselecciona Activar verificación de MD5 para restaurar.</string>
<string name="md5_fail_match">MD5 no coincide en \'{1}\'.</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Fallo al desencriptar el archivo tar '{1}'</string>
<string name="format_data_msg">Quizás necesites reiniciar el recovery para ser capaz de usar /data de nuevo.</string>
<string name="format_data_err">Incapaz de formatear para remover encriptación.</string>
diff --git a/gui/theme/common/languages/fr.xml b/gui/theme/common/languages/fr.xml
index a1891ad4a..f38446110 100644
--- a/gui/theme/common/languages/fr.xml
+++ b/gui/theme/common/languages/fr.xml
@@ -553,7 +553,8 @@
<string name="repair_resize">Réparation de {1} avant de redimensionner.</string>
<string name="unable_resize">Incapable de redimensionner {1}.</string>
<string name="no_md5_found">Pas de fichier md5 trouvé pour '{1}'. Veuillez désactiver la vérification MD5 pour effectuer la restauration.</string>
- <string name="md5_fail_match">Le MD5 ne corresponds pas pour '{1}'.</string>
+ <string name="md5_fail_match">Le MD5 ne correspond pas pour '{1}'.</string>
+ <string name="md5_matched">Le MD5 correspond pour '{1}'.</string>
<string name="restoring">Restauration en cours</string>
<string name="format_data_msg">Vous aurez peut-être à redémarrer pour pouvoir utiliser /data à nouveau.</string>
<string name="format_data_err">Incapable de formater pour enlever l'encryption.</string>
diff --git a/gui/theme/common/languages/hu.xml b/gui/theme/common/languages/hu.xml
index a8b525a0a..ce142189b 100644
--- a/gui/theme/common/languages/hu.xml
+++ b/gui/theme/common/languages/hu.xml
@@ -572,6 +572,7 @@
<string name="unable_resize">Nem lehet átméretezni: {1}.</string>
<string name="no_md5_found">Nem található MD5 fájl ehhez: \'{1}\'. Kérjük, a visszaállításhoz szüntesse meg a kijelölést: \"MD5 ellenőrzés engedélyezése\".</string>
<string name="md5_fail_match">MD5 nem egyezik ezzel: \'{1}\'.</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Nem sikerült visszafejteni a(z) \'{1}\' tar fájlt</string>
<string name="format_data_msg">Lehet, hogy a recovery-be kell újraindítania ahhoz, hogy képes legyen használni az /adat partíciót.</string>
<string name="format_data_err">Nem sikerült formázni a titkosítás eltávolításához.</string>
diff --git a/gui/theme/common/languages/it.xml b/gui/theme/common/languages/it.xml
index 30ba8bbe0..24c8ba074 100644
--- a/gui/theme/common/languages/it.xml
+++ b/gui/theme/common/languages/it.xml
@@ -572,6 +572,7 @@
<string name="unable_resize">Impossibile ridimensionare {1}.</string>
<string name="no_md5_found">Nessun MD5 trovato per '{1}'. Deseleziona "Abilita verifica MD5" per procedere con il ripristino.</string>
<string name="md5_fail_match">Il valore MD5 non corrisponde per '{1}'.</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Decriptazione fallita per il file Tar '{1}'</string>
<string name="format_data_msg">Potresti dover riavviare la Recovery per accedere nuovamente a Data.</string>
<string name="format_data_err">Impossibile formattare al fine di rimuovere la crittografia.</string>
diff --git a/gui/theme/common/languages/nl.xml b/gui/theme/common/languages/nl.xml
index cb03d1096..340ce6d24 100644
--- a/gui/theme/common/languages/nl.xml
+++ b/gui/theme/common/languages/nl.xml
@@ -572,6 +572,7 @@
<string name="unable_resize">Kan de grootte van {1} niet wijzigen.</string>
<string name="no_md5_found">Geen md5 bestand gevonden voor \'{1}\'. Gelieve MD5 controle inschakelen uitzetten om te herstellen.</string>
<string name="md5_fail_match">MD5 vergelijken mislukt op \'{1}\'.</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Het decoderen van tar bestand \'{1}\' is mislukt</string>
<string name="format_data_msg">U zou in recovery moeten herstarten om /data opnieuw te kunnen gebruiken.</string>
<string name="format_data_err">Kan niet formatteren om encryptie te verwijderen.</string>
diff --git a/gui/theme/common/languages/pl.xml b/gui/theme/common/languages/pl.xml
index b28a488b2..7721421a4 100644
--- a/gui/theme/common/languages/pl.xml
+++ b/gui/theme/common/languages/pl.xml
@@ -572,6 +572,7 @@
<string name="unable_resize">Nie można zmienić rozmiaru {1}.</string>
<string name="no_md5_found">Nie znaleziono pliku MD5 '{1}'. Proszę wyłączyć weryfikację MD5, aby przywrócić.</string>
<string name="md5_fail_match">MD5 nie pasuje do '{1}'.</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Nie udało się odszyfrować pliku tar '{1}'</string>
<string name="format_data_msg">Może być konieczne ponowne uruchomienie recovery, aby móc ponownie użyć /date.</string>
<string name="format_data_err">Nie można sformatować, aby usunąć szyfrowanie.</string>
diff --git a/gui/theme/common/languages/pt_BR.xml b/gui/theme/common/languages/pt_BR.xml
index 23c0f804d..f747631cb 100644
--- a/gui/theme/common/languages/pt_BR.xml
+++ b/gui/theme/common/languages/pt_BR.xml
@@ -542,6 +542,7 @@
<string name="unable_resize">Não é possível redimensionar {1}.</string>
<string name="no_md5_found">Nenhum arquivo md5 foi encontrado para \'{1}\'. Por favor, cancelar a seleção de verificação MD5 habilitar para restaurar.</string>
<string name="md5_fail_match">MD5 não conseguiram corresponder na \'{1}\'.</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Falha ao descriptografar arquivo tar \'{1}\'</string>
<string name="format_data_msg">Você pode precisar reiniciar recuperação para ser capaz de usar /data novamente.</string>
<string name="format_data_err">Não é possível formatar para remover a criptografia.</string>
diff --git a/gui/theme/common/languages/ru.xml b/gui/theme/common/languages/ru.xml
index 485d1e85b..8be304541 100644
--- a/gui/theme/common/languages/ru.xml
+++ b/gui/theme/common/languages/ru.xml
@@ -573,6 +573,7 @@
<string name="unable_resize">Не удается изменить размер {1}.</string>
<string name="no_md5_found">Отсутствует файл md5 для '{1}'. Пожалуйста отмените выбор проверки MD5 при восстановлении.</string>
<string name="md5_fail_match">MD5 не соответствует для '{1}'.</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Не удается расшифровать tar-файл '{1}'</string>
<string name="format_data_msg">Вам, возможно, потребуется перезагрузись рекавери, чтобы иметь возможность использовать /data снова.</string>
<string name="format_data_err">Невозможно отформатировать и удалить шифрование.</string>
diff --git a/gui/theme/common/languages/sk.xml b/gui/theme/common/languages/sk.xml
index 544a12260..4773579fd 100644
--- a/gui/theme/common/languages/sk.xml
+++ b/gui/theme/common/languages/sk.xml
@@ -542,6 +542,7 @@
<string name="unable_resize">Nemožno natiahnuť {1}.</string>
<string name="no_md5_found">Súbor MD5 sa nenašiel pre \'{1}\'. Prosím zvoľte Vypnúť kontrolu MD5 počas obnovy.</string>
<string name="md5_fail_match">MD5 nezodpovedá súboru \'{1}\'.</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Nemožno dešifrovať súbor tar \'{1}\'</string>
<string name="format_data_msg">Mali by ste reštartovať recovery aby ste mohli znova používať /data.</string>
<string name="format_data_err">Nemožno formátovať pre zrušenie šifrovania.</string>
diff --git a/gui/theme/common/languages/sl.xml b/gui/theme/common/languages/sl.xml
index 8b120156e..2bf2ffe7b 100644
--- a/gui/theme/common/languages/sl.xml
+++ b/gui/theme/common/languages/sl.xml
@@ -542,6 +542,7 @@
<string name="unable_resize">Velikosti {1} ni mogoče spremeniti.</string>
<string name="no_md5_found">Za \'{1}\' ni bilo najdene datoteke MD5. Odstranite izbiro \'Omogoči preverjanje razpršila MD5\' za obnovitev.</string>
<string name="md5_fail_match">Ujemanje razpršila MD5 na \'{1}\' je spodletelo.</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Odšifriranje datoteke TAR \'{1}\' je spodletelo</string>
<string name="format_data_msg">Za ponovno uporabo /data boste morda morali ponovno zagnati obnovitev.</string>
<string name="format_data_err">Formatiranje za odstranitev šifriranja ni mogoče.</string>
diff --git a/gui/theme/extra-languages/languages/ja.xml b/gui/theme/extra-languages/languages/ja.xml
index 8b1973f31..552665e96 100644
--- a/gui/theme/extra-languages/languages/ja.xml
+++ b/gui/theme/extra-languages/languages/ja.xml
@@ -566,6 +566,7 @@
<string name="unable_resize">{1} をリサイズできません。</string>
<string name="no_md5_found">\'{1}\' の MD5 ファイルが見つかりません。リストアするには MD5 の検証を無効化してください。</string>
<string name="md5_fail_match">\'{1}\' で MD5 が一致しません。</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">tar ファイル '{1}' を復号できませんでした</string>
<string name="format_data_msg">/data を再度使用するにはリカバリを再起動してください。</string>
<string name="format_data_err">暗号化を解除するための初期化ができません。</string>
diff --git a/gui/theme/extra-languages/languages/zh_CN.xml b/gui/theme/extra-languages/languages/zh_CN.xml
index 0d8bfd3a8..ef2042f63 100644
--- a/gui/theme/extra-languages/languages/zh_CN.xml
+++ b/gui/theme/extra-languages/languages/zh_CN.xml
@@ -571,6 +571,7 @@
<string name="unable_resize">无法修改 {1} 大小。</string>
<string name="no_md5_found">无法为 '{1}' 找到 MD5 校验文件。请取消允许 MD5 校验选项。</string>
<string name="md5_fail_match">MD5 校验失败 '{1}'。</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">解密 tar 文件 '{1}' 失败</string>
<string name="format_data_msg">你可能需要重启 recovery 才能使用/data。</string>
<string name="format_data_err">无法格式化并删除加密。</string>
diff --git a/gui/theme/extra-languages/languages/zh_TW.xml b/gui/theme/extra-languages/languages/zh_TW.xml
index b7d6b1e7a..860b6cc27 100644
--- a/gui/theme/extra-languages/languages/zh_TW.xml
+++ b/gui/theme/extra-languages/languages/zh_TW.xml
@@ -571,6 +571,7 @@
<string name="unable_resize">無法調整{1}大小。</string>
<string name="no_md5_found">未找到'{1}'MD5校驗檔案,請取消“啟用MD5校驗備份檔案”選項。</string>
<string name="md5_fail_match">'{1}' MD5校驗失敗。</string>
+ <string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">無法解密tar檔案:'{1}'</string>
<string name="format_data_msg">您可能需要重啟recovery才能使用/data。</string>
<string name="format_data_err">無法格式化並刪除加密。</string>
diff --git a/partition.cpp b/partition.cpp
index f22a283df..d6cadf902 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -1612,52 +1612,48 @@ bool TWPartition::Backup(PartitionSettings *part_settings, pid_t *tar_fork_pid)
return false;
}
+bool TWPartition::Check_Restore_File_MD5(const string& Filename) {
+ twrpDigest md5sum;
+
+ md5sum.setfn(Filename);
+ switch (md5sum.verify_md5digest()) {
+ case MD5_OK:
+ gui_msg(Msg("md5_matched=MD5 matched for '{1}'.")(Filename));
+ return true;
+ case MD5_FILE_UNREADABLE:
+ case MD5_NOT_FOUND:
+ gui_msg(Msg(msg::kError, "no_md5_found=No md5 file found for '{1}'. Please unselect Enable MD5 verification to restore.")(Filename));
+ break;
+ case MD5_MATCH_FAIL:
+ gui_msg(Msg(msg::kError, "md5_fail_match=MD5 failed to match on '{1}'.")(Filename));
+ break;
+ }
+ return false;
+}
+
bool TWPartition::Check_MD5(PartitionSettings *part_settings) {
- string Full_Filename, md5file;
+ string Full_Filename;
char split_filename[512];
int index = 0;
- twrpDigest md5sum;
sync();
- memset(split_filename, 0, sizeof(split_filename));
Full_Filename = part_settings->Backup_Folder + "/" + Backup_FileName;
if (!TWFunc::Path_Exists(Full_Filename)) {
// This is a split archive, we presume
- sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index);
- LOGINFO("split_filename: %s\n", split_filename);
- md5file = split_filename;
- md5file += ".md5";
- if (!TWFunc::Path_Exists(md5file)) {
- gui_msg(Msg(msg::kError, "no_md5_found=No md5 file found for '{1}'. Please unselect Enable MD5 verification to restore.")(split_filename));
- return false;
- }
- md5sum.setfn(split_filename);
+ memset(split_filename, 0, sizeof(split_filename));
while (index < 1000) {
- if (TWFunc::Path_Exists(split_filename) && md5sum.verify_md5digest() != 0) {
- gui_msg(Msg(msg::kError, "md5_fail_match=MD5 failed to match on '{1}'.")(split_filename));
+ sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index);
+ if (!TWFunc::Path_Exists(split_filename))
+ break;
+ LOGINFO("split_filename: %s\n", split_filename);
+ if (!Check_Restore_File_MD5(split_filename))
return false;
- }
index++;
- sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index);
- md5sum.setfn(split_filename);
}
return true;
- } else {
- // Single file archive
- md5file = Full_Filename + ".md5";
- if (!TWFunc::Path_Exists(md5file)) {
- gui_msg(Msg(msg::kError, "no_md5_found=No md5 file found for '{1}'. Please unselect Enable MD5 verification to restore.")(md5file));
- return false;
- }
- md5sum.setfn(Full_Filename);
- if (md5sum.verify_md5digest() != 0) {
- gui_msg(Msg(msg::kError, "md5_fail_match=MD5 failed to match on '{1}'.")(split_filename));
- return false;
- } else
- return true;
}
- return false;
+ return Check_Restore_File_MD5(Full_Filename); // Single file archive
}
bool TWPartition::Restore(PartitionSettings *part_settings) {
diff --git a/partitions.hpp b/partitions.hpp
index e301d9c70..4b9354fd8 100644
--- a/partitions.hpp
+++ b/partitions.hpp
@@ -156,6 +156,7 @@ private:
string Get_Restore_File_System(PartitionSettings *part_settings); // Returns the file system that was in place at the time of the backup
bool Restore_Tar(PartitionSettings *part_settings); // Restore using tar for file systems
bool Restore_Image(PartitionSettings *part_settings); // Restore using dd for images
+ bool Check_Restore_File_MD5(const string& Filename); // Verifies MD5 matches for a file before restoration
bool Get_Size_Via_statfs(bool Display_Error); // Get Partition size, used, and free space using statfs
bool Get_Size_Via_df(bool Display_Error); // Get Partition size, used, and free space using df command
bool Make_Dir(string Path, bool Display_Error); // Creates a directory if it doesn't already exist
diff --git a/twinstall.cpp b/twinstall.cpp
index c2f98febc..50d286c45 100644
--- a/twinstall.cpp
+++ b/twinstall.cpp
@@ -296,9 +296,18 @@ extern "C" int TWinstall_zip(const char* path, int* wipe_cache) {
gui_msg("check_for_md5=Checking for MD5 file...");
twrpDigest md5sum;
md5sum.setfn(path);
- int md5_return = md5sum.verify_md5digest();
- if (md5_return == -2) { // md5 did not match
- LOGERR("Aborting zip install\n");
+ switch (md5sum.verify_md5digest()) {
+ case MD5_OK:
+ gui_msg(Msg("md5_matched=MD5 matched for '{1}'.")(path));
+ break;
+ case MD5_NOT_FOUND:
+ gui_msg("no_md5=Skipping MD5 check: no MD5 file found");
+ break;
+ case MD5_FILE_UNREADABLE:
+ LOGERR("Skipping MD5 check: MD5 file unreadable\n");
+ break;
+ case MD5_MATCH_FAIL: // md5 did not match
+ LOGERR("Aborting zip install: MD5 verification failed\n");
return INSTALL_CORRUPT;
}
}
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;
}
diff --git a/twrpDigest.hpp b/twrpDigest.hpp
index 7ec25edad..ec4a65f75 100644
--- a/twrpDigest.hpp
+++ b/twrpDigest.hpp
@@ -20,6 +20,14 @@ extern "C" {
#include "digest/md5.h"
}
+/* verify_md5digest return codes */
+enum {
+ MD5_MATCH_FAIL = -2, // -2: md5 did not match
+ MD5_NOT_FOUND, // -1: no md5 file found
+ MD5_OK, // 0: md5 matches
+ MD5_FILE_UNREADABLE // 1: md5 file unreadable
+};
+
using namespace std;
class twrpDigest