forked from Imagelibrary/rtems
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>
This commit is contained in:
committed by
Joel Sherrill
parent
1ce89bdf14
commit
45be19a34a
@@ -255,6 +255,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);
|
||||
|
||||
Reference in New Issue
Block a user