summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--applypatch/imgdiff.cpp20
-rw-r--r--update_verifier/Android.mk5
-rw-r--r--update_verifier/update_verifier.cpp31
3 files changed, 41 insertions, 15 deletions
diff --git a/applypatch/imgdiff.cpp b/applypatch/imgdiff.cpp
index f6087de01..528daf113 100644
--- a/applypatch/imgdiff.cpp
+++ b/applypatch/imgdiff.cpp
@@ -224,6 +224,7 @@ unsigned char* ReadZip(const char* filename,
for (i = 0; i < cdcount; ++i) {
if (!(cd[0] == 0x50 && cd[1] == 0x4b && cd[2] == 0x01 && cd[3] == 0x02)) {
printf("bad central directory entry %d\n", i);
+ free(temp_entries);
return NULL;
}
@@ -320,6 +321,10 @@ unsigned char* ReadZip(const char* filename,
// -15 means we are decoding a 'raw' deflate stream; zlib will
// not expect zlib headers.
int ret = inflateInit2(&strm, -15);
+ if (ret < 0) {
+ printf("failed to initialize inflate: %d\n", ret);
+ return NULL;
+ }
strm.avail_out = curr->len;
strm.next_out = curr->data;
@@ -445,6 +450,10 @@ unsigned char* ReadImage(const char* filename,
// -15 means we are decoding a 'raw' deflate stream; zlib will
// not expect zlib headers.
int ret = inflateInit2(&strm, -15);
+ if (ret < 0) {
+ printf("failed to initialize inflate: %d\n", ret);
+ return NULL;
+ }
do {
strm.avail_out = allocated - curr->len;
@@ -552,10 +561,18 @@ int TryReconstruction(ImageChunk* chunk, unsigned char* out) {
int ret;
ret = deflateInit2(&strm, chunk->level, chunk->method, chunk->windowBits,
chunk->memLevel, chunk->strategy);
+ if (ret < 0) {
+ printf("failed to initialize deflate: %d\n", ret);
+ return -1;
+ }
do {
strm.avail_out = BUFFER_SIZE;
strm.next_out = out;
ret = deflate(&strm, Z_FINISH);
+ if (ret < 0) {
+ printf("failed to deflate: %d\n", ret);
+ return -1;
+ }
size_t have = BUFFER_SIZE - strm.avail_out;
if (memcmp(out, chunk->deflate_data+p, have) != 0) {
@@ -1062,6 +1079,9 @@ int main(int argc, char** argv) {
}
}
+ free(patch_data);
+ free(patch_size);
+
fclose(f);
return 0;
diff --git a/update_verifier/Android.mk b/update_verifier/Android.mk
index 8449c758d..49d19b0e1 100644
--- a/update_verifier/Android.mk
+++ b/update_verifier/Android.mk
@@ -24,7 +24,10 @@ LOCAL_SHARED_LIBRARIES := \
libbase \
libcutils \
libhardware \
- liblog
+ liblog \
+ libutils \
+ libhidlbase \
+ android.hardware.boot@1.0
LOCAL_CFLAGS := -Werror
LOCAL_C_INCLUDES += $(LOCAL_PATH)/..
diff --git a/update_verifier/update_verifier.cpp b/update_verifier/update_verifier.cpp
index 93ac605b1..e97a3adba 100644
--- a/update_verifier/update_verifier.cpp
+++ b/update_verifier/update_verifier.cpp
@@ -45,7 +45,12 @@
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <cutils/properties.h>
-#include <hardware/boot_control.h>
+#include <android/hardware/boot/1.0/IBootControl.h>
+
+using android::sp;
+using android::hardware::boot::V1_0::IBootControl;
+using android::hardware::boot::V1_0::BoolResult;
+using android::hardware::boot::V1_0::CommandResult;
constexpr auto CARE_MAP_FILE = "/data/ota_package/care_map.txt";
constexpr int BLOCKSIZE = 4096;
@@ -142,21 +147,18 @@ int main(int argc, char** argv) {
LOG(INFO) << "Started with arg " << i << ": " << argv[i];
}
- const hw_module_t* hw_module;
- if (hw_get_module("bootctrl", &hw_module) != 0) {
+ sp<IBootControl> module = IBootControl::getService("bootctrl");
+ if (module == nullptr) {
LOG(ERROR) << "Error getting bootctrl module.";
return -1;
}
- boot_control_module_t* module = reinterpret_cast<boot_control_module_t*>(
- const_cast<hw_module_t*>(hw_module));
- module->init(module);
-
- unsigned current_slot = module->getCurrentSlot(module);
- int is_successful= module->isSlotMarkedSuccessful(module, current_slot);
- LOG(INFO) << "Booting slot " << current_slot << ": isSlotMarkedSuccessful=" << is_successful;
+ uint32_t current_slot = module->getCurrentSlot();
+ BoolResult is_successful = module->isSlotMarkedSuccessful(current_slot);
+ LOG(INFO) << "Booting slot " << current_slot << ": isSlotMarkedSuccessful="
+ << static_cast<int32_t>(is_successful);
- if (is_successful == 0) {
+ if (is_successful == BoolResult::FALSE) {
// The current slot has not booted successfully.
char verity_mode[PROPERTY_VALUE_MAX];
if (property_get("ro.boot.veritymode", verity_mode, "") == -1) {
@@ -175,9 +177,10 @@ int main(int argc, char** argv) {
return -1;
}
- int ret = module->markBootSuccessful(module);
- if (ret != 0) {
- LOG(ERROR) << "Error marking booted successfully: " << strerror(-ret);
+ CommandResult cr;
+ module->markBootSuccessful([&cr](CommandResult result) { cr = result; });
+ if (!cr.success) {
+ LOG(ERROR) << "Error marking booted successfully: " << cr.errMsg;
return -1;
}
LOG(INFO) << "Marked slot " << current_slot << " as booted successfully.";