[PATCH 7/8] common/cli.c: use memdup_nul() in run_command_list()
Rasmus Villemoes
ravi at prevas.dk
Sun Apr 12 21:59:46 CEST 2026
Use memdup_nul() instead of open-coding it.
Signed-off-by: Rasmus Villemoes <ravi at prevas.dk>
---
common/cli.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/common/cli.c b/common/cli.c
index 4694a35cd0e..ccf7e26e821 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -138,11 +138,9 @@ int run_command_list(const char *cmd, int len, int flag)
#endif
}
if (need_buff) {
- buff = malloc(len + 1);
+ buff = memdup_nul(cmd, len);
if (!buff)
return 1;
- memcpy(buff, cmd, len);
- buff[len] = '\0';
}
#ifdef CONFIG_HUSH_PARSER
if (use_hush_old()) {
--
2.53.0
More information about the U-Boot
mailing list