[PATCH] Fix buffer overflow in iomux_replace_device()

Yuichiro Goto goto at k-tech.co.jp
Fri Apr 23 09:45:41 CEST 2021

Use of strcat() against an uninitialized buffer would lead
to buffer overflow. This patch fixes it.

Signed-off-by: Yuichiro Goto <goto at k-tech.co.jp>
Cc: Peter Robinson <pbrobinson at gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
Cc: Nicolas Saenz Julienne <nsaenzjulienne at suse.de>

This patch seems to solve the boot problem on a 32-bit mode RPi3
with a USB keyboard connected. I would appreciate it very much
if you test this patch for other boards.

 common/iomux.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/common/iomux.c b/common/iomux.c
index b9088aa3b5..27baca6931 100644
--- a/common/iomux.c
+++ b/common/iomux.c
@@ -158,7 +158,10 @@ int iomux_replace_device(const int console, const char *old, const char *new)
 			return -ENOMEM;
-		strcat(tmp, ",");
+		if (!arg)
+			strcpy(tmp, ",");
+		else
+			strcat(tmp, ",");
 		strcat(tmp, name);
 		arg = tmp;

More information about the U-Boot mailing list