fs_mgr: avb check avb_slot_data

Damaged avb metadata can result in avb_slot_verify returning a
nullptr in avb_slot_data.  Instead of an illegal access
violation in first_stage_init, we return the verify_result so
that it can be acted upon.

Test: confirm happenstance damaged vbmeta does not crash init.
Change-Id: I15be5bd32760bcc3418c5d8a943b016c0ddd56bc
This commit is contained in:
Mark Salyzyn 2019-01-11 10:01:17 -08:00
parent d75913a371
commit 6a56a2a94f

View file

@ -186,6 +186,7 @@ AvbSlotVerifyResult FsManagerAvbOps::AvbSlotVerify(const std::string& ab_suffix,
avb_slot_verify(&avb_ops_, requested_partitions, ab_suffix.c_str(), flags,
AVB_HASHTREE_ERROR_MODE_RESTART_AND_INVALIDATE, &avb_slot_data);
if (!avb_slot_data) return verify_result;
// Copies avb_slot_data->vbmeta_images[].
for (size_t i = 0; i < avb_slot_data->num_vbmeta_images; i++) {
out_vbmeta_images->emplace_back(VBMetaData(avb_slot_data->vbmeta_images[i].vbmeta_data,