summaryrefslogtreecommitdiff
path: root/libfdt/fdt_ro.c
diff options
context:
space:
mode:
author Pierre-Clément Tosi <ptosi@google.com> 2022-09-13 16:58:15 +0100
committer Mike McTernan <mikemcternan@google.com> 2022-09-23 08:09:50 +0000
commita6ac6d916df145366bcb34f5507d5da213b2ebaf (patch)
tree4e184f0460d3161448af0e439c9b2945836c7fd8 /libfdt/fdt_ro.c
parentc8e7fc52971868cf6bbba6d4934b32fe95ad3169 (diff)
libfdt: fdt_path_offset_namelen: Reject empty paths
Make empty paths result in FDT_ERR_BADPATH. Per the specification (v0.4-rc4): > The convention for specifying a device path is: > /node-name-1/node-name-2/node-name-N > > The path to the root node is /. > > A unit address may be omitted if the full path to the > node is unambiguous. Bug: 246465319 Test: libfdt_fuzzer # clusterfuzz/testcase-detail/4530863420604416 Change-Id: I14ab0a074ab994c1f598243d2d5795d2cd9a853a (cherry picked from commit 3c28f3e3a1724c288d19f1b1a139cf57bfe1af33)
Diffstat (limited to 'libfdt/fdt_ro.c')
-rw-r--r--libfdt/fdt_ro.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index e03570a..7a65dfe 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -253,6 +253,9 @@ int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen)
FDT_RO_PROBE(fdt);
+ if (namelen < 1)
+ return -FDT_ERR_BADPATH;
+
/* see if we have an alias */
if (*path != '/') {
const char *q = memchr(path, '/', end - p);