Merge "Add include/ to the Makefile include path." am: 38234f4bef
am: 1b688e8039
* commit '1b688e8039a26b7deb9217487f99136d2afcc688':
Add include/ to the Makefile include path.
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 1693fa1..d2a7ac9 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"
@@ -93,12 +95,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.
@@ -112,7 +113,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;
@@ -139,7 +140,7 @@
State state;
state.cookie = &updater_info;
- state.script = script;
+ state.script = &script[0];
state.errmsg = NULL;
char* result = Evaluate(&state, root);
@@ -172,7 +173,5 @@
mzCloseZipArchive(updater_info.package_zip);
}
sysReleaseMap(&map);
- free(script);
-
return 0;
}