]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
IOMUX: Fix buffer overflow in iomux_replace_device()
authorYuichiro Goto <goto@k-tech.co.jp>
Sun, 25 Apr 2021 23:08:03 +0000 (08:08 +0900)
committerStefan Roese <sr@denx.de>
Wed, 28 Apr 2021 08:05:13 +0000 (10:05 +0200)
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 <goto@k-tech.co.jp>
Cc: Peter Robinson <pbrobinson@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
common/iomux.c

index b9088aa3b58b2dea12d77ee66d3ad77193fc6bd5..c428f7110a7a790d5d8c95a05a604c721fdba7a0 100644 (file)
@@ -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;