[Skiboot] [PATCH] libfdt: add basic sanity check to fdt_open_into

Stewart Smith stewart at linux.vnet.ibm.com
Tue Nov 17 17:06:55 AEDT 2015


Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 libfdt/fdt_rw.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index 994037bbbda9..befe87dcf88f 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -425,6 +425,10 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
 	newsize = FDT_ALIGN(sizeof(struct fdt_header), 8) + mem_rsv_size
 		+ struct_size + fdt_size_dt_strings(fdt);
 
+	/* basic sanity check */
+	if (struct_size > bufsize)
+		return -FDT_ERR_BADSTRUCTURE;
+
 	if (bufsize < newsize)
 		return -FDT_ERR_NOSPACE;
 
-- 
2.1.4



More information about the Skiboot mailing list