public inbox for devicetree-compiler@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libfdt: fdt_path_offset_namelen: Reject empty path
@ 2023-10-06 12:48 Pierre-Clément Tosi
  2023-10-06 13:22 ` Simon Glass
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Pierre-Clément Tosi @ 2023-10-06 12:48 UTC (permalink / raw)
  To: David Gibson; +Cc: devicetree-compiler

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.

Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
---
 libfdt/fdt_ro.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index c4c520c..46b4ef5 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -255,6 +255,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);
-- 
2.42.0.609.gbb76f46606-goog


-- 
Pierre

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-10-08  2:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-06 12:48 [PATCH] libfdt: fdt_path_offset_namelen: Reject empty path Pierre-Clément Tosi
2023-10-06 13:22 ` Simon Glass
2023-10-07 11:17   ` Pierre-Clément Tosi
2023-10-08  2:32   ` David Gibson
2023-10-06 14:06 ` Rob Herring
2023-10-06 22:42   ` Simon Glass
2023-10-07 11:21     ` Pierre-Clément Tosi
2023-10-08  2:32 ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox