public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] tools/mkimage: ignore trailing garbage
@ 2008-12-03 11:35 Peter Korsgaard
  2008-12-03 11:35 ` [U-Boot] [PATCH v2] tools/mkimage: use lseek rather than fstat for file size for -l option Peter Korsgaard
  2008-12-03 11:55 ` [U-Boot] [PATCH v2] tools/mkimage: ignore trailing garbage Wolfgang Denk
  0 siblings, 2 replies; 5+ messages in thread
From: Peter Korsgaard @ 2008-12-03 11:35 UTC (permalink / raw)
  To: u-boot

Ignore trailing data after the uimage data and only complain if the
file is too small.

(E.G. if the uImage was stored in flash and hence padded to the flash
sector size).

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 tools/mkimage.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

Changes since v1:
- Fix a compiler warning on 64bit

diff --git a/tools/mkimage.c b/tools/mkimage.c
index 967fe9a..b19cd6f 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -523,7 +523,14 @@ image_verify_header (char *ptr, int image_size)
 	}
 
 	data = ptr + sizeof(image_header_t);
-	len  = image_size - sizeof(image_header_t) ;
+	len  = ntohl(hdr->ih_size);
+	if (len > (image_size - sizeof(image_header_t))) {
+		fprintf (stderr,
+			"%s: ERROR: \"%s\" is too short (%d vs %d bytes)!\n",
+			 cmdname, imagefile,
+			 image_size - (int)sizeof(image_header_t), len);
+		exit (EXIT_FAILURE);
+	}
 
 	if (crc32 (0, data, len) != ntohl(hdr->ih_dcrc)) {
 		fprintf (stderr,
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-12-03 12:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-03 11:35 [U-Boot] [PATCH v2] tools/mkimage: ignore trailing garbage Peter Korsgaard
2008-12-03 11:35 ` [U-Boot] [PATCH v2] tools/mkimage: use lseek rather than fstat for file size for -l option Peter Korsgaard
2008-12-03 11:55   ` Wolfgang Denk
2008-12-03 12:08     ` Peter Korsgaard
2008-12-03 11:55 ` [U-Boot] [PATCH v2] tools/mkimage: ignore trailing garbage Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox