Skip to content

Commit 6540f17

Browse files
committed
Fixed more comments from copilot + fenrir
1 parent e6c1976 commit 6540f17

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/update_flash.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,11 @@ static int wolfBoot_delta_update(struct wolfBoot_image *boot,
632632
return -1;
633633
}
634634
delta_img_size = wb_delta_im2n(*img_size);
635-
if (inverse)
635+
if (inverse) {
636636
delta_img_offset = wb_delta_im2n(*img_offset);
637+
} else {
638+
delta_img_offset = IMAGE_HEADER_SIZE;
639+
}
637640
cur_v = wolfBoot_current_firmware_version();
638641
upd_v = wolfBoot_update_firmware_version();
639642
delta_base_v = wolfBoot_get_diffbase_version(PART_UPDATE);
@@ -691,7 +694,7 @@ static int wolfBoot_delta_update(struct wolfBoot_image *boot,
691694
ret = -1;
692695
} else {
693696
ret = wb_patch_init(&ctx, boot->hdr, boot->fw_size + IMAGE_HEADER_SIZE,
694-
update->hdr + IMAGE_HEADER_SIZE, delta_img_size);
697+
update->hdr + delta_img_offset, delta_img_size);
695698
}
696699
}
697700
if (ret < 0)
@@ -1488,6 +1491,10 @@ void RAMFUNCTION wolfBoot_start(void)
14881491
}
14891492
}
14901493
}
1494+
if ((boot.hdr_ok != 1U) || (boot.sha_ok != 1U) ||
1495+
(boot.signature_ok != 1U)) {
1496+
wolfBoot_panic();
1497+
}
14911498
PART_SANITY_CHECK(&boot);
14921499
#else
14931500
if (bootRet < 0) {

src/x86/ahci.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ static int wolfBoot_local_constant_compare(const uint8_t* a, const uint8_t* b,
122122
return diff;
123123
}
124124

125+
static void ahci_secret_zeroize(void *ptr, size_t len)
126+
{
127+
volatile uint8_t *p = (volatile uint8_t *)ptr;
128+
while (len-- > 0U) {
129+
*p++ = 0U;
130+
}
131+
}
132+
125133
/**
126134
* @brief Sets the AHCI Base Address Register (ABAR) for the given device.
127135
*
@@ -278,7 +286,7 @@ static int sata_get_random_base64(uint8_t *out, int *out_size)
278286
ret = 0;
279287

280288
cleanup:
281-
TPM2_ForceZero(rand, sizeof(rand));
289+
ahci_secret_zeroize(rand, sizeof(rand));
282290
return ret;
283291
}
284292

@@ -322,7 +330,7 @@ static int sata_create_and_seal_unlock_secret(const uint8_t *pubkey_hint,
322330
}
323331

324332
wolfBoot_printf("Secret Check %d bytes\n", secret_check_sz);
325-
TPM2_ForceZero(secret_check, sizeof(secret_check));
333+
ahci_secret_zeroize(secret_check, sizeof(secret_check));
326334
}
327335

328336
if (ret == 0)
@@ -495,7 +503,7 @@ int sata_unlock_disk(int drv, int freeze)
495503
error:
496504
r = -1;
497505
cleanup:
498-
TPM2_ForceZero(secret, sizeof(secret));
506+
ahci_secret_zeroize(secret, sizeof(secret));
499507
return r;
500508
}
501509
#endif /* WOLFBOOT_ATA_DISK_LOCK */

0 commit comments

Comments
 (0)