]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fastboot: fix CRC32 chunk size checking
authorWojciech Nizinski <niziak@spox.org>
Mon, 25 Sep 2023 10:37:15 +0000 (12:37 +0200)
committerMattijs Korpershoek <mkorpershoek@baylibre.com>
Tue, 31 Oct 2023 13:36:30 +0000 (14:36 +0100)
genimage create android-sparse file with CRC32 chunk at end. When
U-Boot's fastboot receives this chunk it returns error message:
`Fail Bogus chunk size for chunk type Dont Care`

According to reference implementation of Android's sparse file format:

<https://android.googlesource.com/platform/system/core/+/refs/heads/main/
libsparse/output_file.cpp#513>

the chunk_header.total_sz is CHUNK_HEADER_LEN + 4 (CRC32 size).

Signed-off-by: Wojciech Nizinski <niziak@spox.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # on vim3
Link: https://lore.kernel.org/r/20230925103714.4153612-1-niziak@spox.org
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
lib/image-sparse.c

index 8f8a67e158044d37909822252f67c4a1f716ecd1..323aad981c6493ebd5225a9281b5bc6c9d865373 100644 (file)
@@ -289,8 +289,8 @@ int write_sparse_image(struct sparse_storage *info,
 
                case CHUNK_TYPE_CRC32:
                        if (chunk_header->total_sz !=
-                           sparse_header->chunk_hdr_sz) {
-                               info->mssg("Bogus chunk size for chunk type Dont Care",
+                           sparse_header->chunk_hdr_sz + sizeof(uint32_t)) {
+                               info->mssg("Bogus chunk size for chunk type CRC32",
                                           response);
                                return -1;
                        }