diff options
author | 2023-10-10 10:28:22 +0100 | |
---|---|---|
committer | 2023-10-11 17:02:20 +0100 | |
commit | b202d115bde8094148e386c34978910926f93f60 (patch) | |
tree | b5d48511119f5041137bc60b961a3829845c60c2 /libfdt/fdt_ro.c | |
parent | 10b6dbab709bf16f3a5f497b273819cafc9286bf (diff) |
FROMGIT: libfdt: fdt_path_offset_namelen: Reject empty path
Reject empty paths and negative lengths, according to the DT spec v0.4:
The convention for specifying a device path is:
/node-name-1/node-name-2/node-name-N
The path to the root node is /.
This prevents the access to path[0] from ever being out-of-bounds.
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
Message-ID: <20231010092822.qo2nxc3g47t26dqs@google.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Test: N/A
Change-Id: I8efee39a06fa62f1f057a975e8133a295be0a656
Diffstat (limited to 'libfdt/fdt_ro.c')
-rw-r--r-- | libfdt/fdt_ro.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c index 7912463..53db8ce 100644 --- a/libfdt/fdt_ro.c +++ b/libfdt/fdt_ro.c @@ -263,6 +263,9 @@ int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen) FDT_RO_PROBE(fdt); + if (!can_assume(VALID_INPUT) && namelen <= 0) + return -FDT_ERR_BADPATH; + /* see if we have an alias */ if (*path != '/') { const char *q = memchr(path, '/', end - p); |