From: Yuichiro Goto Date: Sun, 25 Apr 2021 23:08:03 +0000 (+0900) Subject: IOMUX: Fix buffer overflow in iomux_replace_device() X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=b104caa9a497b7d6f3a3df3462f37bf92265e26f;p=u-boot.git IOMUX: Fix buffer overflow in iomux_replace_device() Use of strcat() against an uninitialized buffer would lead to buffer overflow. This patch fixes it. Fixes: 694cd5618c ("IOMUX: Introduce iomux_replace_device()") Signed-off-by: Yuichiro Goto Cc: Peter Robinson Cc: Andy Shevchenko Cc: Nicolas Saenz Julienne Reviewed-by: Andy Shevchenko Tested-by: Peter Robinson --- diff --git a/common/iomux.c b/common/iomux.c index b9088aa3b5..c428f7110a 100644 --- a/common/iomux.c +++ b/common/iomux.c @@ -158,8 +158,12 @@ int iomux_replace_device(const int console, const char *old, const char *new) return -ENOMEM; } - strcat(tmp, ","); - strcat(tmp, name); + if (arg) { + strcat(tmp, ","); + strcat(tmp, name); + } + else + strcpy(tmp, name); arg = tmp; size = strlen(tmp) + 1;