diff options
author | Tianjie Xu <xunchang@google.com> | 2017-03-23 01:45:51 +0100 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-23 01:45:51 +0100 |
commit | 5e1a2dc5227d86761b43b39a93a83dfd95975de4 (patch) | |
tree | 9e4357aa169dac1a093adc1ffc70d12d71f59c6d /updater/blockimg.cpp | |
parent | Merge "Fix the permission of stashed blocks created by updater" am: d882b8892a am: deb2a29a42 (diff) | |
parent | Merge "Remove malloc in edify functions" am: 1ea869b0c6 (diff) | |
download | android_bootable_recovery-5e1a2dc5227d86761b43b39a93a83dfd95975de4.tar android_bootable_recovery-5e1a2dc5227d86761b43b39a93a83dfd95975de4.tar.gz android_bootable_recovery-5e1a2dc5227d86761b43b39a93a83dfd95975de4.tar.bz2 android_bootable_recovery-5e1a2dc5227d86761b43b39a93a83dfd95975de4.tar.lz android_bootable_recovery-5e1a2dc5227d86761b43b39a93a83dfd95975de4.tar.xz android_bootable_recovery-5e1a2dc5227d86761b43b39a93a83dfd95975de4.tar.zst android_bootable_recovery-5e1a2dc5227d86761b43b39a93a83dfd95975de4.zip |
Diffstat (limited to '')
-rw-r--r-- | updater/blockimg.cpp | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index 8dbd8c7d1..efdfec19a 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -1470,8 +1470,9 @@ struct Command { // - new data stream (filename within package.zip) // - patch stream (filename within package.zip, must be uncompressed) -static Value* PerformBlockImageUpdate(const char* name, State* state, int /* argc */, Expr* argv[], - const Command* commands, size_t cmdcount, bool dryrun) { +static Value* PerformBlockImageUpdate(const char* name, State* state, + const std::vector<std::unique_ptr<Expr>>& argv, + const Command* commands, size_t cmdcount, bool dryrun) { CommandParameters params = {}; params.canwrite = !dryrun; @@ -1480,9 +1481,14 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, int /* arg is_retry = true; LOG(INFO) << "This update is a retry."; } + if (argv.size() != 4) { + ErrorAbort(state, kArgsParsingFailure, "block_image_update expects 4 arguments, got %zu", + argv.size()); + return StringValue(""); + } std::vector<std::unique_ptr<Value>> args; - if (!ReadValueArgs(state, 4, argv, &args)) { + if (!ReadValueArgs(state, argv, &args)) { return nullptr; } @@ -1762,7 +1768,8 @@ pbiudone: // command has already been completed and verify the integrity of // the source data. -Value* BlockImageVerifyFn(const char* name, State* state, int argc, Expr* argv[]) { +Value* BlockImageVerifyFn(const char* name, State* state, + const std::vector<std::unique_ptr<Expr>>& argv) { // Commands which are not tested are set to nullptr to skip them completely const Command commands[] = { { "bsdiff", PerformCommandDiff }, @@ -1776,11 +1783,12 @@ Value* BlockImageVerifyFn(const char* name, State* state, int argc, Expr* argv[] }; // Perform a dry run without writing to test if an update can proceed - return PerformBlockImageUpdate(name, state, argc, argv, commands, + return PerformBlockImageUpdate(name, state, argv, commands, sizeof(commands) / sizeof(commands[0]), true); } -Value* BlockImageUpdateFn(const char* name, State* state, int argc, Expr* argv[]) { +Value* BlockImageUpdateFn(const char* name, State* state, + const std::vector<std::unique_ptr<Expr>>& argv) { const Command commands[] = { { "bsdiff", PerformCommandDiff }, { "erase", PerformCommandErase }, @@ -1792,13 +1800,19 @@ Value* BlockImageUpdateFn(const char* name, State* state, int argc, Expr* argv[] { "zero", PerformCommandZero } }; - return PerformBlockImageUpdate(name, state, argc, argv, commands, + return PerformBlockImageUpdate(name, state, argv, commands, sizeof(commands) / sizeof(commands[0]), false); } -Value* RangeSha1Fn(const char* name, State* state, int /* argc */, Expr* argv[]) { +Value* RangeSha1Fn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { + if (argv.size() != 2) { + ErrorAbort(state, kArgsParsingFailure, "range_sha1 expects 2 arguments, got %zu", + argv.size()); + return StringValue(""); + } + std::vector<std::unique_ptr<Value>> args; - if (!ReadValueArgs(state, 2, argv, &args)) { + if (!ReadValueArgs(state, argv, &args)) { return nullptr; } @@ -1856,9 +1870,16 @@ Value* RangeSha1Fn(const char* name, State* state, int /* argc */, Expr* argv[]) // 1st block of each partition and check for mounting time/count. It return string "t" // if executes successfully and an empty string otherwise. -Value* CheckFirstBlockFn(const char* name, State* state, int argc, Expr* argv[]) { +Value* CheckFirstBlockFn(const char* name, State* state, + const std::vector<std::unique_ptr<Expr>>& argv) { + if (argv.size() != 1) { + ErrorAbort(state, kArgsParsingFailure, "check_first_block expects 1 argument, got %zu", + argv.size()); + return StringValue(""); + } + std::vector<std::unique_ptr<Value>> args; - if (!ReadValueArgs(state, 1, argv, &args)) { + if (!ReadValueArgs(state, argv, &args)) { return nullptr; } @@ -1904,9 +1925,16 @@ Value* CheckFirstBlockFn(const char* name, State* state, int argc, Expr* argv[]) } -Value* BlockImageRecoverFn(const char* name, State* state, int argc, Expr* argv[]) { +Value* BlockImageRecoverFn(const char* name, State* state, + const std::vector<std::unique_ptr<Expr>>& argv) { + if (argv.size() != 2) { + ErrorAbort(state, kArgsParsingFailure, "block_image_recover expects 2 arguments, got %zu", + argv.size()); + return StringValue(""); + } + std::vector<std::unique_ptr<Value>> args; - if (!ReadValueArgs(state, 2, argv, &args)) { + if (!ReadValueArgs(state, argv, &args)) { return nullptr; } |