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>
*/
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");