firmware_handler: prevent writing metadata w/o data handler
The notion of writing to metadata in this application is only relevant
if there's a data handler. Add a check to verify there is a data
handler present, otherwise return false.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ib2ffbf5c6560186e56e919a0ebc6ed1e2e8e04d3
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index c7164dc..8daead6 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -510,9 +510,14 @@
return false;
}
- /* TODO: Prevent writing meta to the verification blob. */
+ /* Prevent writing meta to the verification blob (it has no data handler).
+ */
+ if (item->second->dataHandler)
+ {
+ return item->second->dataHandler->writeMeta(data);
+ }
- return item->second->dataHandler->writeMeta(data);
+ return false;
}
/*