From c2420845391bb8b50cb782c5fee95f0fa643e49c Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Tue, 27 Feb 2018 17:05:39 -0800 Subject: Fix the behavior of undefined commands in BlockImageVerify In BlockImageVerify some commands are undefined, e.g. "erase", "new", "zero". And we should not error out if the corresponding function pointer of these commands is null; otherwise we will fail the verification. The old code is: if (cmd->f != nullptr && cmd->f(params) == -1) return false; In the last_command_file change the logic was wrongly modified to if (cmd->f == nullptr) return false; ... if (cmd->f(params) == -1) return false; Test: sideload an incremental OTA twice on bullhead Change-Id: I2561c365badb850da0e416629ccd61f0df7da5d7 --- updater/blockimg.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index feb2aeb27..4f085b204 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -1727,9 +1727,11 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, const Command* cmd = cmd_map[params.cmdname]; + // Skip the command if we explicitly set the corresponding function pointer to nullptr, e.g. + // "erase" during block_image_verify. if (cmd->f == nullptr) { - LOG(ERROR) << "failed to find the function for command [" << line << "]"; - goto pbiudone; + LOG(DEBUG) << "skip executing command [" << line << "]"; + continue; } // Skip all commands before the saved last command index when resuming an update. -- cgit v1.2.3