From 9a1c801a1a3c102bf95c5339c9e985b26b823a21 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Tue, 6 Jan 2026 14:19:30 -0500 Subject: Fix discarded const qualifiers It's unsafe to implicitly discard the const qualifier on a pointer. In overlay_fixup_phandle(), this was probably just an oversight, and making the "sep" variable a const char * is sufficient to fix it. In create_node(), however, the "p" variable is directly modifying the buffer pointed to by "const char* node_name". To fix this, we need to actually make a duplicate of the buffer and operate on that instead. This introduces a malloc()/free() and an unbounded strdup() into the operation, but fdtput isn't a long-running service and the node_name argument comes directly from argv, so this shouldn't introduce a significant performance impact. Signed-off-by: Stephen Gallagher Signed-off-by: David Gibson --- libfdt/fdt_overlay.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libfdt') diff --git a/subprojects/dtc/libfdt/fdt_overlay.c b/subprojects/dtc/libfdt/fdt_overlay.c index e6b9eb6..51a3859 100644 --- a/subprojects/dtc/libfdt/fdt_overlay.c +++ b/subprojects/dtc/libfdt/fdt_overlay.c @@ -407,7 +407,8 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off, const char *fixup_str = value; uint32_t path_len, name_len; uint32_t fixup_len; - char *sep, *endptr; + const char *sep; + char *endptr; int poffset, ret; fixup_end = memchr(value, '\0', len); -- cgit 1.2.3-korg .