Commit 9feea8c6 authored by David Brown's avatar David Brown Committed by Andrzej Puzdrowski
Browse files

boot: Check that hash TLV is sufficiently large

Add a check for the size of the TLV entry for the boot record.
Although, this is in the protected area, and should be protected by a
signature, check that we don't induce an integer underflow if that entry
is somehow too short.

Signed-off-by: default avatarDavid Brown <david.brown@linaro.org>
parent 254714be
Loading
Loading
Loading
Loading
+7 −0
Changes for boot/bootutil/src/boot_record.c: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -196,6 +196,13 @@ boot_save_boot_status(uint8_t sw_module,
        return -1;
    }

    /* Ensure that we have enough in the record for the hash.  This
     * prevents an underflow in the calculation below.
     */
    if (record_len < sizeof(image_hash)) {
	return -1;
    }

    /* Update the measurement value (hash of the image) data item in the
     * boot record. It is always the last item in the structure to make
     * it easy to calculate its position.