Merge "Move dumpkey tool to the recovery repo." am: 5197fde242 am: b652678953
am: 95b96d98ca
* commit '95b96d98caf6dbaefcfe7b52ba35d27babd70245':
Move dumpkey tool to the recovery repo.
diff --git a/minzip/SysUtil.c b/minzip/SysUtil.c
index e7dd17b..de47edf 100644
--- a/minzip/SysUtil.c
+++ b/minzip/SysUtil.c
@@ -8,6 +8,7 @@
#include <fcntl.h>
#include <limits.h>
#include <stdbool.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -118,13 +119,13 @@
break;
}
size_t length = (end - start) * blksize;
- if (end <= start || (end - start) > SIZE_MAX / blksize || length > remaining_size) {
- LOGE("unexpected range in block map: %zu %zu\n", start, end);
- success = false;
- break;
+ if (end <= start || ((end - start) > SIZE_MAX / blksize) || length > remaining_size) {
+ LOGE("unexpected range in block map: %zu %zu\n", start, end);
+ success = false;
+ break;
}
- void* addr = mmap64(next, length, PROT_READ, MAP_PRIVATE | MAP_FIXED, fd, ((off64_t)start)*blksize);
+ void* addr = mmap64(next, length, PROT_READ, MAP_PRIVATE | MAP_FIXED, fd, ((off64_t)(start*blksize)));
if (addr == MAP_FAILED) {
LOGE("failed to map block %d: %s\n", i, strerror(errno));
success = false;
@@ -137,14 +138,14 @@
remaining_size -= length;
}
if (success && remaining_size != 0) {
- LOGE("ranges in block map are invalid: remaining_size = %zu\n", remaining_size);
- success = false;
+ LOGE("ranges in block map are invalid: remaining_size = %zu\n", remaining_size);
+ success = false;
}
if (!success) {
- close(fd);
- munmap(reserve, blocks * blksize);
- free(pMap->ranges);
- return -1;
+ close(fd);
+ munmap(reserve, blocks * blksize);
+ free(pMap->ranges);
+ return -1;
}
close(fd);
diff --git a/updater/updater.cpp b/updater/updater.cpp
index efb4a8c..0d58f64 100644
--- a/updater/updater.cpp
+++ b/updater/updater.cpp
@@ -19,6 +19,8 @@
#include <stdlib.h>
#include <string.h>
+#include <string>
+
#include "edify/expr.h"
#include "updater.h"
#include "install.h"
@@ -91,12 +93,11 @@
return 4;
}
- char* script = reinterpret_cast<char*>(malloc(script_entry->uncompLen+1));
- if (!mzReadZipEntry(&za, script_entry, script, script_entry->uncompLen)) {
+ 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");
return 5;
}
- script[script_entry->uncompLen] = '\0';
// Configure edify's functions.
@@ -110,7 +111,7 @@
Expr* root;
int error_count = 0;
- int error = parse_string(script, &root, &error_count);
+ int error = parse_string(script.c_str(), &root, &error_count);
if (error != 0 || error_count > 0) {
printf("%d parse errors\n", error_count);
return 6;
@@ -137,7 +138,7 @@
State state;
state.cookie = &updater_info;
- state.script = script;
+ state.script = &script[0];
state.errmsg = NULL;
char* result = Evaluate(&state, root);
@@ -165,7 +166,5 @@
mzCloseZipArchive(updater_info.package_zip);
}
sysReleaseMap(&map);
- free(script);
-
return 0;
}