mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 06:48:16 +00:00
boardloader: ensure check_sdcard fails when read fails
This commit is contained in:
parent
2ebd2b1b6b
commit
430900ea2c
@ -40,13 +40,15 @@ static uint32_t check_sdcard(void)
|
|||||||
|
|
||||||
uint32_t buf[IMAGE_HEADER_SIZE / sizeof(uint32_t)];
|
uint32_t buf[IMAGE_HEADER_SIZE / sizeof(uint32_t)];
|
||||||
|
|
||||||
sdcard_read_blocks(buf, 0, IMAGE_HEADER_SIZE / SDCARD_BLOCK_SIZE);
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
|
const secbool read_status = sdcard_read_blocks(buf, 0, IMAGE_HEADER_SIZE / SDCARD_BLOCK_SIZE);
|
||||||
|
|
||||||
sdcard_power_off();
|
sdcard_power_off();
|
||||||
|
|
||||||
image_header hdr;
|
image_header hdr;
|
||||||
|
|
||||||
if (sectrue == load_image_header((const uint8_t *)buf, BOOTLOADER_IMAGE_MAGIC, BOOTLOADER_IMAGE_MAXSIZE, BOARDLOADER_KEY_M, BOARDLOADER_KEY_N, BOARDLOADER_KEYS, &hdr)) {
|
if ((sectrue == read_status) && (sectrue == load_image_header((const uint8_t *)buf, BOOTLOADER_IMAGE_MAGIC, BOOTLOADER_IMAGE_MAXSIZE, BOARDLOADER_KEY_M, BOARDLOADER_KEY_N, BOARDLOADER_KEYS, &hdr))) {
|
||||||
return hdr.codelen;
|
return hdr.codelen;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user