This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new d48d8ef5a fsutils/mkgpt: fix GPT header CRC check on 64-bit targets
d48d8ef5a is described below
commit d48d8ef5a6214ff6dc23b1b7eb7ca9612e3cac10
Author: anpeiyun <[email protected]>
AuthorDate: Sun Aug 16 19:12:59 2026 +0800
fsutils/mkgpt: fix GPT header CRC check on 64-bit targets
The GPT header/entries CRC was computed with ~0l, a long literal that is
64-bit on arm64, making verify_gpt_pratition() compare the uint32_t CRC
against a 64-bit value so it always failed with "Header CRC is wrong".
Use ~0u to keep the CRC computed and compared in 32-bit.
Signed-off-by: anpeiyun <[email protected]>
Signed-off-by: jingfei <[email protected]>
---
fsutils/mkgpt/mkgpt.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fsutils/mkgpt/mkgpt.c b/fsutils/mkgpt/mkgpt.c
index 994902067..d967c6af2 100644
--- a/fsutils/mkgpt/mkgpt.c
+++ b/fsutils/mkgpt/mkgpt.c
@@ -342,12 +342,12 @@ static void update_crc32(FAR struct efi_ptable_s *ptbl)
n = crc32part((FAR const uint8_t *)ptbl->entry,
sizeof(ptbl->entry[0]) *
- ptbl->header.entries_count, ~0l) ^ ~0l;
+ ptbl->header.entries_count, ~0u) ^ ~0u;
ptbl->header.entries_crc32 = n;
ptbl->header.crc32 = 0;
n = crc32part((FAR const uint8_t *)&ptbl->header,
- sizeof(ptbl->header), ~0l) ^ ~0l;
+ sizeof(ptbl->header), ~0u) ^ ~0u;
ptbl->header.crc32 = n;
}
@@ -373,7 +373,7 @@ static int verify_gpt_pratition(FAR struct efi_ptable_s
*ptbl)
orgcrc = hdr->crc32;
hdr->crc32 = 0;
if (orgcrc != (crc32part((FAR const uint8_t *)hdr,
- sizeof(*hdr), ~0l) ^ ~0l))
+ sizeof(*hdr), ~0u) ^ ~0u))
{
fprintf(stderr, "GPT: Header CRC is wrong\n");
return -1;
@@ -387,7 +387,7 @@ static int verify_gpt_pratition(FAR struct efi_ptable_s
*ptbl)
}
if (hdr->entries_crc32 != (crc32part((FAR const uint8_t *)ptbl->entry,
- sizeof(ptbl->entry[0]) * ptbl->header.entries_count, ~0l) ^ ~0l))
+ sizeof(ptbl->entry[0]) * ptbl->header.entries_count, ~0u) ^ ~0u))
{
fprintf(stderr, "GPT: Header entry signature is wrong\n");
return -1;