IOMUX: Fix buffer overflow in iomux_replace_device()
PATCH v2 1/1 IOMUX: Fix buffer overflow in iomux_replace_device()
Use of strcat() against an uninitialized buffer would lead to buffer overflow. This patch fixes it.
---
Changes for v2:
- Add "IOMUX" in title
common/iomux.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
common/iomux.c +4 -1
@@ -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
PATCH v2 1/1 IOMUX: Fix buffer overflow in iomux_replace_device()
Quoted 2 lines · Yuichiro Goto
Use of
strcat()against an uninitialized buffer would lead to buffer overflow. This patch fixes it.
Thanks for report!
Can you also add a Fixes tag?
Quoted 17 lines
Signed-off-by Yuichiro Goto <[email protected]>Cc Peter Robinson <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Nicolas Saenz Julienne <[email protected]>---
Changes for v2:
- Add "IOMUX" in titlecommon/iomux.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)common/iomux.c +0
-0
common/iomux.c int iomux_replace_device(const int console, const char *old, const char *new) · line 165
Quoted 9 lines
common/iomux.c +4
-1@@ -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);
It would be better to have it like
if (arg) {
strcat(tmp, ",");
strcat(tmp, name);
} else
strcpy(tmp, name);common/iomux.c int iomux_replace_device(const int console, const char *old, const char *new) · line 167
Quoted 1 line
common/iomux.c +0
-0arg = tmp;
Peter, does it fix your issue seen on ARMv7?
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 1/1 IOMUX: Fix buffer overflow in iomux_replace_device()
Quoted 45 lines · Andy Shevchenko
Quoted 2 lines · Yuichiro Goto
Use of
strcat()against an uninitialized buffer would lead to buffer overflow. This patch fixes it.Thanks for report!
Can you also add a Fixes tag?
Quoted 17 lines
Signed-off-by Yuichiro Goto <[email protected]>Cc Peter Robinson <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Nicolas Saenz Julienne <[email protected]>---
Changes for v2:
- Add "IOMUX" in titlecommon/iomux.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)common/iomux.c +0
-0common/iomux.c int iomux_replace_device(const int console, const char *old, const char *new) · line 165
Quoted 9 lines
common/iomux.c +4
-1@@ -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);It would be better to have it like
if (arg) { strcat(tmp, ","); strcat(tmp, name); } else strcpy(tmp, name);
Quoted 9 lines
common/iomux.c int iomux_replace_device(const int console, const char *old, const char *new) · line 167
Quoted 1 line
common/iomux.c +0
-0arg = tmp;Peter, does it fix your issue seen on ARMv7?
--
With Best Regards,
Andy Shevchenko
Hi Andy,
Thank you for your review. I submitted the patch v3 based on you suggestions.
Signature · 2 lines
Kind Regards, Yuichiro Goto