lshal: Fix empty hidl_array access.
Fix this error:
Abort message: 'Check failed: bytes != nullptr || len == 0 0x0 32'
This bug is introduced by the change below.
!hashRet.isOk() should have a break; in it like the other error cases.
The change below added this code after the error which used to be
the end of the statement.
Bug: 329190736
Fixes: b670dd7e0c1562db
("lshal: Fix mem invalid access (timeoutIPC callers)")
Test: TH
Change-Id: Iada52b2ca033105962727fcccf651fbb5bdd5736
diff --git a/cmds/lshal/ListCommand.cpp b/cmds/lshal/ListCommand.cpp
index 870e8eb..0c1feb8 100644
--- a/cmds/lshal/ListCommand.cpp
+++ b/cmds/lshal/ListCommand.cpp
@@ -731,16 +731,17 @@
[hashChain](const auto& ret) { *hashChain = std::move(ret); });
if (!hashRet.isOk()) {
handleError(TRANSACTION_ERROR, "getHashChain failed: " + hashRet.description());
+ break; // skip getHashChain
}
if (static_cast<size_t>(hashIndex) >= hashChain->size()) {
handleError(BAD_IMPL,
"interfaceChain indicates position " + std::to_string(hashIndex) +
" but getHashChain returns " + std::to_string(hashChain->size()) +
" hashes");
- } else {
- auto&& hashArray = (*hashChain)[hashIndex];
- entry->hash = android::base::HexString(hashArray.data(), hashArray.size());
+ break; // skip getHashChain
}
+ auto&& hashArray = (*hashChain)[hashIndex];
+ entry->hash = android::base::HexString(hashArray.data(), hashArray.size());
} while (0);
if (status == OK) {
entry->serviceStatus = ServiceStatus::ALIVE;