summaryrefslogtreecommitdiff
path: root/lib/libavb/avb_descriptor.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2019-11-01 09:23:21 -0400
committerTom Rini <trini@konsulko.com>2019-11-01 09:23:21 -0400
commit82679624f9aa6d1be733c46f3555d5166b6f5b72 (patch)
tree8a99cf79bc520b833e155094ef134c0526b1f005 /lib/libavb/avb_descriptor.c
parent412326d1bc2d346d7b4faad6fa547eaf065681a2 (diff)
parent5d80a1a93d42c8325d65516cc654ff6a9ceec58a (diff)
downloadu-boot-82679624f9aa6d1be733c46f3555d5166b6f5b72.tar.gz
Merge branch '2019-10-30-master-imports'
- Migrate test.py to use python3 and current pytest. - NVMe bugfixes - Assorted other fixes - Android AVB updates.
Diffstat (limited to 'lib/libavb/avb_descriptor.c')
-rw-r--r--lib/libavb/avb_descriptor.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/libavb/avb_descriptor.c b/lib/libavb/avb_descriptor.c
index fb0b305f2c..9f03b9777a 100644
--- a/lib/libavb/avb_descriptor.c
+++ b/lib/libavb/avb_descriptor.c
@@ -72,7 +72,11 @@ bool avb_descriptor_foreach(const uint8_t* image_data,
const AvbDescriptor* dh = (const AvbDescriptor*)p;
avb_assert_aligned(dh);
uint64_t nb_following = avb_be64toh(dh->num_bytes_following);
- uint64_t nb_total = sizeof(AvbDescriptor) + nb_following;
+ uint64_t nb_total = 0;
+ if (!avb_safe_add(&nb_total, sizeof(AvbDescriptor), nb_following)) {
+ avb_error("Invalid descriptor length.\n");
+ goto out;
+ }
if ((nb_total & 7) != 0) {
avb_error("Invalid descriptor length.\n");
@@ -88,7 +92,10 @@ bool avb_descriptor_foreach(const uint8_t* image_data,
goto out;
}
- p += nb_total;
+ if (!avb_safe_add_to((uint64_t*)(&p), nb_total)) {
+ avb_error("Invalid descriptor length.\n");
+ goto out;
+ }
}
ret = true;