Skip to contentSkip to conversation

Fix buffer overflow in iomux_replace_device()

PATCH Superseded Yuichiro Goto 1 participant 1 message Apr 23, 2021

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix buffer overflow in iomux_replace_device()

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

Cc Peter Robinson <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Nicolas Saenz Julienne <[email protected]>

---

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(-)
common/iomux.c +4 -1
index b9088aa3b5..27baca6931 100644
@@ -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;
Signature · 1 line
2.17.1