From 11168813bf9c088e1fce8a96f4b493ee815c966b Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Tue, 21 Apr 2026 09:54:37 +0200 Subject: common/cli.c: use memdup_nul() in run_command_list() Use memdup_nul() instead of open-coding it. Reviewed-by: Simon Glass Signed-off-by: Rasmus Villemoes --- common/cli.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'common/cli.c') 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()) { -- cgit v1.3.1