diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2021-01-13 02:09:12 +0100 |
---|---|---|
committer | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2021-01-13 02:38:00 +0100 |
commit | ea1a9ec5f430359720d9a0621ed1acfbba6a142a (patch) | |
tree | 082f34fbda5ba90e3af478d145aedc96024c2bd1 /common | |
parent | 5dad05a0e61d759af2df8cf900d044a8485bd747 (diff) | |
download | u-boot-ea1a9ec5f430359720d9a0621ed1acfbba6a142a.tar.gz u-boot-ea1a9ec5f430359720d9a0621ed1acfbba6a142a.tar.xz u-boot-ea1a9ec5f430359720d9a0621ed1acfbba6a142a.zip |
image-fit: fit_check_format check for valid FDT
fit_check_format() must check that the buffer contains a flattened device
tree before calling any device tree library functions.
Failure to do may cause segmentation faults.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/image-fit.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/common/image-fit.c b/common/image-fit.c index 6a8787ca0a..21c44bdf69 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1553,6 +1553,12 @@ int fit_image_check_comp(const void *fit, int noffset, uint8_t comp) */ int fit_check_format(const void *fit) { + /* A FIT image must be a valid FDT */ + if (fdt_check_header(fit)) { + debug("Wrong FIT format: not a flattened device tree\n"); + return 0; + } + /* mandatory / node 'description' property */ if (fdt_getprop(fit, 0, FIT_DESC_PROP, NULL) == NULL) { debug("Wrong FIT format: no description\n"); |