The code foresees that parameters descriptor_size and descriptor_count
might be NULL and then dereferences them without further check.
The size check must take into account the descriptor count.
ImageInfo might be NULL. In this case we must not dereference it.
Fixes: 4ac6041c3cbf ("efi: ESRT creation tests")
Addresses-Coverity-ID: CID 569497: Null pointer dereferences (FORWARD_NULL)
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
if (package_version_name)
*package_version_name = NULL;
- if (*image_info_size < sizeof(*image_info)) {
- *image_info_size = *descriptor_size * *descriptor_count;
+ if (*image_info_size < sizeof(*image_info) * TEST_ESRT_NUM_ENTRIES) {
+ *image_info_size = sizeof(*image_info) * TEST_ESRT_NUM_ENTRIES;
return EFI_BUFFER_TOO_SMALL;
}
+ if (!image_info)
+ return EFI_INVALID_PARAMETER;
for (int idx = 0; idx < TEST_ESRT_NUM_ENTRIES; idx++)
image_info[idx] = static_img_info[idx];