summaryrefslogtreecommitdiff
path: root/cmd/bootm.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-02-16 03:08:09 +0300
committerTom Rini <trini@konsulko.com>2021-02-16 06:31:52 +0300
commitc5819701a3de61e2ba2ef7ad0b616565b32305e5 (patch)
tree2d78afc29b784d5477102dabfc94215781126ae0 /cmd/bootm.c
parentd5f3aadacbc63df3b690d6fd9f0aa3f575b43356 (diff)
downloadu-boot-c5819701a3de61e2ba2ef7ad0b616565b32305e5.tar.xz
image: Adjust the workings of fit_check_format()
At present this function does not accept a size for the FIT. This means that it must be read from the FIT itself, introducing potential security risk. Update the function to include a size parameter, which can be invalid, in which case fit_check_format() calculates it. For now no callers pass the size, but this can be updated later. Also adjust the return value to an error code so that all the different types of problems can be distinguished by the user. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Bruce Monroe <bruce.monroe@intel.com> Reported-by: Arie Haenel <arie.haenel@intel.com> Reported-by: Julien Lenoir <julien.lenoir@intel.com>
Diffstat (limited to 'cmd/bootm.c')
-rw-r--r--cmd/bootm.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/cmd/bootm.c b/cmd/bootm.c
index 7732b97f63..81c6b93978 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -292,7 +292,7 @@ static int image_info(ulong addr)
case IMAGE_FORMAT_FIT:
puts(" FIT image found\n");
- if (!fit_check_format(hdr)) {
+ if (fit_check_format(hdr, IMAGE_SIZE_INVAL)) {
puts("Bad FIT image format!\n");
unmap_sysmem(hdr);
return 1;
@@ -369,7 +369,7 @@ static int do_imls_nor(void)
#endif
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
- if (!fit_check_format(hdr))
+ if (fit_check_format(hdr, IMAGE_SIZE_INVAL))
goto next_sector;
printf("FIT Image at %08lX:\n", (ulong)hdr);
@@ -449,7 +449,7 @@ static int nand_imls_fitimage(struct mtd_info *mtd, int nand_dev, loff_t off,
return ret;
}
- if (!fit_check_format(imgdata)) {
+ if (fit_check_format(imgdata, IMAGE_SIZE_INVAL)) {
free(imgdata);
return 0;
}