summaryrefslogtreecommitdiff
path: root/libfec
diff options
context:
space:
mode:
authorTianjie <xunchang@google.com>2020-05-29 17:18:44 -0700
committerTianjie <xunchang@google.com>2020-05-29 17:18:44 -0700
commit90e7155bdd10039448bbc5ee4636f14c0119718e (patch)
treec678ef0929240c94b8d4f9059e18c874728fd388 /libfec
parent8279e6342e4a79b6579129f1ab05dddd27688c94 (diff)
downloadextras-90e7155bdd10039448bbc5ee4636f14c0119718e.tar.gz
Fix the parsing of images without hashtree descriptor
It's possible that the an image doesn't contain a hashtree descriptor. And the current raises a segfault when we attempt to validate and copy a non existing descriptor. Bug: 157778739 Test: call fec_open on dtbo image. Change-Id: Ieb5acf016ceeb547f2b23de43d4276ea4d013a6f
Diffstat (limited to 'libfec')
-rw-r--r--libfec/avb_utils.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/libfec/avb_utils.cpp b/libfec/avb_utils.cpp
index 8913f2a1..849556ef 100644
--- a/libfec/avb_utils.cpp
+++ b/libfec/avb_utils.cpp
@@ -82,6 +82,10 @@ int parse_avb_image(fec_handle *f, const std::vector<uint8_t> &vbmeta) {
const AvbHashtreeDescriptor *hashtree_descriptor_ptr = nullptr;
avb_descriptor_foreach(vbmeta.data(), vbmeta.size(), parse_descriptor,
&hashtree_descriptor_ptr);
+ if (!hashtree_descriptor_ptr) {
+ error("failed to find avb hashtree descriptor");
+ return -1;
+ }
AvbHashtreeDescriptor hashtree_descriptor;
if (!avb_hashtree_descriptor_validate_and_byteswap(hashtree_descriptor_ptr,