summaryrefslogtreecommitdiffstats
path: root/updater/updater.cpp
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2016-10-19 00:33:23 +0200
committerTianjie Xu <xunchang@google.com>2016-10-19 00:33:23 +0200
commit81e54eddd4132895d70ab8b2307c693311799e05 (patch)
tree7487e2ea808f9702854bd95f5befefef55ef1c45 /updater/updater.cpp
parentMerge "Change StringValue to use std::string" am: 2b17b24ae5 am: 430b7ae469 (diff)
parentresolve merge conflicts of 6fba98c to stage-aosp-master (diff)
downloadandroid_bootable_recovery-81e54eddd4132895d70ab8b2307c693311799e05.tar
android_bootable_recovery-81e54eddd4132895d70ab8b2307c693311799e05.tar.gz
android_bootable_recovery-81e54eddd4132895d70ab8b2307c693311799e05.tar.bz2
android_bootable_recovery-81e54eddd4132895d70ab8b2307c693311799e05.tar.lz
android_bootable_recovery-81e54eddd4132895d70ab8b2307c693311799e05.tar.xz
android_bootable_recovery-81e54eddd4132895d70ab8b2307c693311799e05.tar.zst
android_bootable_recovery-81e54eddd4132895d70ab8b2307c693311799e05.zip
Diffstat (limited to 'updater/updater.cpp')
-rw-r--r--updater/updater.cpp46
1 files changed, 29 insertions, 17 deletions
diff --git a/updater/updater.cpp b/updater/updater.cpp
index 0d19e53c4..46de9ad09 100644
--- a/updater/updater.cpp
+++ b/updater/updater.cpp
@@ -26,11 +26,12 @@
#include <android-base/strings.h>
#include <selinux/label.h>
#include <selinux/selinux.h>
+#include <ziparchive/zip_archive.h>
#include "config.h"
#include "edify/expr.h"
-#include "minzip/SysUtil.h"
-#include "minzip/Zip.h"
+#include "otautil/DirUtil.h"
+#include "otautil/SysUtil.h"
#include "updater/blockimg.h"
#include "updater/install.h"
@@ -84,25 +85,32 @@ int main(int argc, char** argv) {
printf("failed to map package %s\n", argv[3]);
return 3;
}
- ZipArchive za;
- int err;
- err = mzOpenZipArchive(map.addr, map.length, &za);
- if (err != 0) {
+ ZipArchiveHandle za;
+ int open_err = OpenArchiveFromMemory(map.addr, map.length, argv[3], &za);
+ if (open_err != 0) {
printf("failed to open package %s: %s\n",
- argv[3], strerror(err));
+ argv[3], ErrorCodeString(open_err));
+ CloseArchive(za);
return 3;
}
- ota_io_init(&za);
-
- const ZipEntry* script_entry = mzFindZipEntry(&za, SCRIPT_NAME);
- if (script_entry == NULL) {
- printf("failed to find %s in %s\n", SCRIPT_NAME, package_filename);
+ ota_io_init(za);
+
+ ZipString script_name(SCRIPT_NAME);
+ ZipEntry script_entry;
+ int find_err = FindEntry(za, script_name, &script_entry);
+ if (find_err != 0) {
+ printf("failed to find %s in %s: %s\n", SCRIPT_NAME, package_filename,
+ ErrorCodeString(find_err));
+ CloseArchive(za);
return 4;
}
- std::string script(script_entry->uncompLen, '\0');
- if (!mzReadZipEntry(&za, script_entry, &script[0], script_entry->uncompLen)) {
- printf("failed to read script from package\n");
+ std::string script(script_entry.uncompressed_length, '\0');
+ int extract_err = ExtractToMemory(za, &script_entry, reinterpret_cast<uint8_t*>(&script[0]),
+ script_entry.uncompressed_length);
+ if (extract_err != 0) {
+ printf("failed to read script from package: %s\n", ErrorCodeString(extract_err));
+ CloseArchive(za);
return 5;
}
@@ -120,6 +128,7 @@ int main(int argc, char** argv) {
int error = parse_string(script.c_str(), &root, &error_count);
if (error != 0 || error_count > 0) {
printf("%d parse errors\n", error_count);
+ CloseArchive(za);
return 6;
}
@@ -137,7 +146,7 @@ int main(int argc, char** argv) {
UpdaterInfo updater_info;
updater_info.cmd_pipe = cmd_pipe;
- updater_info.package_zip = &za;
+ updater_info.package_zip = za;
updater_info.version = atoi(version);
updater_info.package_zip_addr = map.addr;
updater_info.package_zip_len = map.length;
@@ -188,13 +197,16 @@ int main(int argc, char** argv) {
}
}
+ if (updater_info.package_zip) {
+ CloseArchive(updater_info.package_zip);
+ }
return 7;
} else {
fprintf(cmd_pipe, "ui_print script succeeded: result was [%s]\n", result.c_str());
}
if (updater_info.package_zip) {
- mzCloseZipArchive(updater_info.package_zip);
+ CloseArchive(updater_info.package_zip);
}
sysReleaseMap(&map);
return 0;