summaryrefslogtreecommitdiffstats
path: root/updater
diff options
context:
space:
mode:
Diffstat (limited to 'updater')
-rw-r--r--updater/install.cpp19
-rw-r--r--updater/updater.cpp13
2 files changed, 13 insertions, 19 deletions
diff --git a/updater/install.cpp b/updater/install.cpp
index 4c4886d51..8c33c2bf3 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -37,6 +37,7 @@
#include <vector>
#include <android-base/parseint.h>
+#include <android-base/properties.h>
#include <android-base/strings.h>
#include <android-base/stringprintf.h>
#include <selinux/label.h>
@@ -46,7 +47,6 @@
#include "applypatch/applypatch.h"
#include "cutils/android_reboot.h"
#include "cutils/misc.h"
-#include "cutils/properties.h"
#include "edify/expr.h"
#include "error_code.h"
#include "minzip/DirUtil.h"
@@ -906,11 +906,10 @@ Value* GetPropFn(const char* name, State* state, int argc, Expr* argv[]) {
char* key = Evaluate(state, argv[0]);
if (key == NULL) return NULL;
- char value[PROPERTY_VALUE_MAX];
- property_get(key, value, "");
+ std::string value = android::base::GetProperty(key, "");
free(key);
- return StringValue(strdup(value));
+ return StringValue(strdup(value.c_str()));
}
@@ -1301,9 +1300,8 @@ Value* RebootNowFn(const char* name, State* state, int argc, Expr* argv[]) {
char* property;
if (ReadArgs(state, argv, 2, &filename, &property) < 0) return NULL;
- char buffer[80];
-
// zero out the 'command' field of the bootloader message.
+ char buffer[80];
memset(buffer, 0, sizeof(((struct bootloader_message*)0)->command));
FILE* f = ota_fopen(filename, "r+b");
fseek(f, offsetof(struct bootloader_message, command), SEEK_SET);
@@ -1311,12 +1309,9 @@ Value* RebootNowFn(const char* name, State* state, int argc, Expr* argv[]) {
ota_fclose(f);
free(filename);
- strcpy(buffer, "reboot,");
- if (property != NULL) {
- strncat(buffer, property, sizeof(buffer)-10);
- }
-
- property_set(ANDROID_RB_PROPERTY, buffer);
+ std::string reboot_cmd = "reboot,";
+ if (property != nullptr) reboot_cmd += property;
+ android::base::SetProperty(ANDROID_RB_PROPERTY, reboot_cmd);
sleep(5);
free(property);
diff --git a/updater/updater.cpp b/updater/updater.cpp
index c222cee0d..9fa01a53c 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"
@@ -96,12 +98,11 @@ int main(int argc, char** argv) {
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.
@@ -115,7 +116,7 @@ int main(int argc, char** argv) {
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;
@@ -142,7 +143,7 @@ int main(int argc, char** argv) {
State state;
state.cookie = &updater_info;
- state.script = script;
+ state.script = &script[0];
state.errmsg = NULL;
if (argc == 5) {
@@ -200,7 +201,5 @@ int main(int argc, char** argv) {
mzCloseZipArchive(updater_info.package_zip);
}
sysReleaseMap(&map);
- free(script);
-
return 0;
}