From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Shevchenko Date: Fri, 23 Apr 2021 16:09:18 +0300 Subject: [PATCH v2] IOMUX: Fix buffer overflow in iomux_replace_device() In-Reply-To: <20210423080805.16535-1-goto@k-tech.co.jp> References: <20210423080805.16535-1-goto@k-tech.co.jp> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Fri, Apr 23, 2021 at 05:08:05PM +0900, Yuichiro Goto wrote: > 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? > Signed-off-by: Yuichiro Goto > Cc: Peter Robinson > Cc: Andy Shevchenko > Cc: Nicolas Saenz Julienne > --- > > Changes for v2: > - Add "IOMUX" in title > > 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); It would be better to have it like if (arg) { strcat(tmp, ","); strcat(tmp, name); } else strcpy(tmp, name); > arg = tmp; Peter, does it fix your issue seen on ARMv7? -- With Best Regards, Andy Shevchenko