summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorYuichiro Goto <[email protected]>2021-04-26 08:08:03 +0900
committerStefan Roese <[email protected]>2021-04-28 10:05:13 +0200
commitb104caa9a497b7d6f3a3df3462f37bf92265e26f (patch)
tree087cd0d30954b31fd4a3575766c295e47d8c78dd /common
parent48594c38edb235d671c544faf922b29a1c1a5d23 (diff)
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 <[email protected]> Cc: Peter Robinson <[email protected]> Cc: Andy Shevchenko <[email protected]> Cc: Nicolas Saenz Julienne <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Tested-by: Peter Robinson <[email protected]>
Diffstat (limited to 'common')
-rw-r--r--common/iomux.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/common/iomux.c b/common/iomux.c
index b9088aa3b58..c428f7110a7 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;