summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorHeinrich Schuchardt <[email protected]>2025-03-04 17:04:03 +0100
committerTom Rini <[email protected]>2025-03-18 08:17:32 -0600
commit15ba2b7356af035bc7dfd5c279e9658291fc7cf3 (patch)
treeda0e1123a476b50ab2061629d96699b92c420b27 /tools
parent301c2ab729447b0f7c602e054c3f22a5a9df1b24 (diff)
dumpimage: fix handling of StarFive SPL too long
The header of the StarFive U-Boot SPL file u-boot-spl.normal.out has a field indicating the payload size. When copying U-Boot SPL from a partition the copied file might be too long. Currently in this situation a misleading error message 'Incorrect CRC32' is written. We must use the payload size and not the file size when calculating the CRC32. Write a warning if the file is too long indicating the correct size. This enables the user to truncate the file accordingly. Signed-off-by: Heinrich Schuchardt <[email protected]>
Diffstat (limited to 'tools')
-rw-r--r--tools/sfspl.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/sfspl.c b/tools/sfspl.c
index c76420ce21b..516e96e8dd9 100644
--- a/tools/sfspl.c
+++ b/tools/sfspl.c
@@ -70,11 +70,14 @@ static int sfspl_verify_header(unsigned char *buf, int size,
printf("Truncated file\n");
return EXIT_FAILURE;
}
+ if ((size_t)size > hdr_size + file_size)
+ printf("File too long, expected %u bytes\n",
+ hdr_size + file_size);
if (hdr->version != DEFAULT_VERSION) {
printf("Unknown file format version\n");
return EXIT_FAILURE;
}
- crc_check = crc32(0, &buf[hdr_size], size - hdr_size);
+ crc_check = crc32(0, &buf[hdr_size], file_size);
if (crc_check != crc) {
printf("Incorrect CRC32\n");
return EXIT_FAILURE;