[U-Boot] [PATCH 1/6] fdt: Check error codes returned from fdtlib when loading ITB

Joe Hershberger joe.hershberger at ni.com
Fri Aug 17 22:34:35 CEST 2012


Before this patch, error codes returned from fdtlib were ignored and
continued access would cause a crash. Now just check if the image is
truncated and error if so.

Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
---
 common/image.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/common/image.c b/common/image.c
index 91954ac..4252e63 100644
--- a/common/image.c
+++ b/common/image.c
@@ -2818,6 +2818,11 @@ int fit_image_check_hashes(const void *fit, int image_noffset)
 		}
 	}
 
+	if (noffset == -FDT_ERR_TRUNCATED || noffset == -FDT_ERR_BADSTRUCTURE) {
+		err_msg = " error!\nCorrupted or truncated tree";
+		goto error;
+	}
+
 	return 1;
 
 error:
-- 
1.7.11.5



More information about the U-Boot mailing list