From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3] IOMUX: Fix buffer overflow in iomux_replace_device()
Date: Mon, 26 Apr 2021 11:35:32 +0300 [thread overview]
Message-ID: <YIZ7VKLIldXSL2rF@smile.fi.intel.com> (raw)
In-Reply-To: <20210425230803.3055-1-goto@k-tech.co.jp>
On Mon, Apr 26, 2021 at 08:08:03AM +0900, Yuichiro Goto wrote:
> Use of strcat() against an uninitialized buffer would lead
> to buffer overflow. This patch fixes it.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 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>
> ---
>
> Changes for v3:
> - Add a Fixes tag in commit message
> - Refactor the patch per suggestion from Andy Shevchenko
>
> Changes for v2:
> - Add "IOMUX" in title
>
> common/iomux.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/common/iomux.c b/common/iomux.c
> index b9088aa3b5..c428f7110a 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;
> --
> 2.17.1
>
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2021-04-26 8:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-25 23:08 [PATCH v3] IOMUX: Fix buffer overflow in iomux_replace_device() Yuichiro Goto
2021-04-26 8:35 ` Andy Shevchenko [this message]
2021-04-27 8:44 ` Peter Robinson
2021-04-27 16:46 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YIZ7VKLIldXSL2rF@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox