Skip to contentSkip to conversation

libfdt: Handle failed get_name() on BEGIN_NODE

PATCH Applied Pierre-Clément Tosi 2 participants 2 messages Jul 14, 2022 – Jul 26, 2022 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libfdt: Handle failed get_name() on BEGIN_NODE

Validate the return value of fdt_get_name() as an ill-formed DT, causing it to fail, could result in fdt_check_full() dereferencing NULL.

Fixes a2def5479950 ("libfdt: Check that the root-node name is empty")
---
 libfdt/fdt_check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libfdt/fdt_check.c +1 -1
index fa410a8..71390ee 100644
@@ -66,7 +66,7 @@ int fdt_check_full(const void *fdt, size_t bufsize)
 				int len;
 
 				name = fdt_get_name(fdt, offset, &len);
-				if (*name || len)
+				if (!name || *name || len)
 					return -FDT_ERR_BADSTRUCTURE;
 			}
 			break;
Signature · 1 line
2.37.0.170.g444d1eabd0-goog

A message that is not in the archive (sent off-list or not yet received): 20220714083848.958492-1-ptosi-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org

Applied
#2 lore raw
Quoted 5 lines · Pierre-Clément Tosi

Validate the return value of fdt_get_name() as an ill-formed DT, causing it to fail, could result in fdt_check_full() dereferencing NULL.

Fixes a2def5479950 ("libfdt: Check that the root-node name is empty")

Applied, thanks. Sorry it took me so long to look at this.

Quoted 17 lines
---
 libfdt/fdt_check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libfdt/fdt_check.c +1 -1
index fa410a8..71390ee 100644
@@ -66,7 +66,7 @@ int fdt_check_full(const void *fdt, size_t bufsize)
 				int len;
 
 				name = fdt_get_name(fdt, offset, &len);
-				if (*name || len)
+				if (!name || *name || len)
 					return -FDT_ERR_BADSTRUCTURE;
 			}
 			break;
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson