Skip to contentSkip to conversation

kexec-tools: Fix CRC calculation for padded uImage

PATCH New Helmut Schaa 1 participant 1 message Apr 20, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kexec-tools: Fix CRC calculation for padded uImage

Instead of calulating the CRC on the whole file just calculate the CRC on the actual uImage length as given by the uImage header. This fixes loading padded uImages, for example from a mtd partition.

---
 kexec/kexec-uImage.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kexec/kexec-uImage.c +1 -1
index 409e516..83e7910 100644
@@ -72,7 +72,7 @@ int uImage_probe(const unsigned char *buf, off_t len, unsigned int arch)
 		return -1;
 	}
 #ifdef HAVE_LIBZ
-	crc = crc32(0, (void *)buf + sizeof(header), len - sizeof(header));
+	crc = crc32(0, (void *)buf + sizeof(header), be32_to_cpu(header.ih_size));
 	if (crc != be32_to_cpu(header.ih_dcrc)) {
 		printf("The data CRC does not match. Computed: %08x "
 				"expected %08x\n", crc,
Signature · 7 lines
1.7.7


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec