mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-11 07:24:46 +00:00
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 <heinrich.schuchardt@canonical.com>
This commit is contained in:
parent
301c2ab729
commit
15ba2b7356
1 changed files with 4 additions and 1 deletions
|
@ -70,11 +70,14 @@ static int sfspl_verify_header(unsigned char *buf, int size,
|
||||||
printf("Truncated file\n");
|
printf("Truncated file\n");
|
||||||
return EXIT_FAILURE;
|
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) {
|
if (hdr->version != DEFAULT_VERSION) {
|
||||||
printf("Unknown file format version\n");
|
printf("Unknown file format version\n");
|
||||||
return EXIT_FAILURE;
|
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) {
|
if (crc_check != crc) {
|
||||||
printf("Incorrect CRC32\n");
|
printf("Incorrect CRC32\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
Loading…
Add table
Reference in a new issue