aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorReinhard Pfau <reinhard.pfau@gdsys.cc>2015-11-29 15:52:14 +0100
committerLuka Perkov <luka.perkov@sartura.hr>2015-11-29 16:02:44 +0100
commit76b391cdee022b2fe2ad5627ec8ee7ebab046c1c (patch)
treecb8bbb4d57f0055b3bfaeb2f62226e0e97e2acd0 /tools
parenta8840dced0745165073b3d7163ee42404da09bdc (diff)
downloadu-boot-76b391cdee022b2fe2ad5627ec8ee7ebab046c1c.zip
u-boot-76b391cdee022b2fe2ad5627ec8ee7ebab046c1c.tar.gz
u-boot-76b391cdee022b2fe2ad5627ec8ee7ebab046c1c.tar.bz2
tools/kwbimage: fix size computations for v1 images
Fix computation of haeder size and binary header size. Size of opt header and some 32bit values were not taken into account. This could result in invalid boot images (due to the wrong binary header size, the image could claim to have another extension header after the binary extension although there is none). Use "uint32_t" instead of "unsigned int" for header size computation. Signed-off-by: Reinhard Pfau <reinhard.pfau@gdsys.cc> Reviewed-by: Stefan Roese <sr@denx.de> Cc: Luka Perkov <luka.perkov@sartura.hr>
Diffstat (limited to 'tools')
-rw-r--r--tools/kwbimage.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index a0ea7d1..369aba7 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -324,8 +324,9 @@ static size_t image_headersz_v1(struct image_tool_params *params,
return 0;
}
- headersz += s.st_size +
- binarye->binary.nargs * sizeof(unsigned int);
+ headersz += sizeof(struct opt_hdr_v1) +
+ s.st_size +
+ (binarye->binary.nargs + 2) * sizeof(uint32_t);
if (hasext)
*hasext = 1;
}
@@ -419,7 +420,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
fstat(fileno(bin), &s);
binhdrsz = sizeof(struct opt_hdr_v1) +
- (binarye->binary.nargs + 1) * sizeof(unsigned int) +
+ (binarye->binary.nargs + 2) * sizeof(uint32_t) +
s.st_size;
/*