mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 01:41:35 +08:00
Fix case were descriptor has no or bad length
This commit is contained in:
committed by
Daniel Agar
parent
5c80b2d3dd
commit
6ea06892ac
@@ -362,7 +362,14 @@ static bool is_app_valid(uint32_t first_word)
|
|||||||
|
|
||||||
length = bootloader.fw_image_descriptor->image_size;
|
length = bootloader.fw_image_descriptor->image_size;
|
||||||
|
|
||||||
if (length > APPLICATION_SIZE) {
|
if (length > APPLICATION_SIZE || length == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t block2_len = bootloader.fw_image_descriptor->image_size - ((size_t)&bootloader.fw_image_descriptor->major_version
|
||||||
|
- (size_t)bootloader.fw_image);
|
||||||
|
|
||||||
|
if (block2_len > APPLICATION_SIZE || block2_len == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,9 +377,7 @@ static bool is_app_valid(uint32_t first_word)
|
|||||||
block_crc1 = crc32_signature(block_crc1, (size_t)(&bootloader.fw_image_descriptor->crc32_block1) -
|
block_crc1 = crc32_signature(block_crc1, (size_t)(&bootloader.fw_image_descriptor->crc32_block1) -
|
||||||
(size_t)(bootloader.fw_image + 1), (const uint8_t *)(bootloader.fw_image + 1));
|
(size_t)(bootloader.fw_image + 1), (const uint8_t *)(bootloader.fw_image + 1));
|
||||||
|
|
||||||
block_crc2 = crc32_signature(0,
|
block_crc2 = crc32_signature(0, block2_len,
|
||||||
(size_t) bootloader.fw_image_descriptor->image_size - ((size_t)&bootloader.fw_image_descriptor->major_version
|
|
||||||
- (size_t)bootloader.fw_image),
|
|
||||||
(const uint8_t *) &bootloader.fw_image_descriptor->major_version);
|
(const uint8_t *) &bootloader.fw_image_descriptor->major_version);
|
||||||
|
|
||||||
#if defined(DEBUG_APPLICATION_INPLACE)
|
#if defined(DEBUG_APPLICATION_INPLACE)
|
||||||
|
|||||||
Reference in New Issue
Block a user