linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Sean Wang <sean.wang@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Matthias Brugger <matthias.bgg@gmail.com>
Cc: linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org
Subject: Re: [PATCH] pinctrl: mediatek: Use scnprintf() for avoiding potential buffer overflow
Date: Thu, 19 Mar 2020 16:53:34 +0100	[thread overview]
Message-ID: <s5hblosuyrl.wl-tiwai@suse.de> (raw)
In-Reply-To: <20200311090644.20287-1-tiwai@suse.de>

On Wed, 11 Mar 2020 10:06:44 +0100,
Takashi Iwai wrote:
> 
> Since snprintf() returns the would-be-output size instead of the
> actual output size, the succeeding calls may go beyond the given
> buffer limit.  Fix it by replacing with scnprintf().
> 
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

A gentle reminder for this forgotten patch.
Let me know if any further change is needed.


thanks,

Takashi

> ---
>  drivers/pinctrl/mediatek/pinctrl-paris.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
> index 3ee8086f5e55..3853ec3a2a8e 100644
> --- a/drivers/pinctrl/mediatek/pinctrl-paris.c
> +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
> @@ -611,7 +611,7 @@ ssize_t mtk_pctrl_show_one_pin(struct mtk_pinctrl *hw,
>  	} else if (pullen != MTK_DISABLE && pullen != MTK_ENABLE) {
>  		pullen = 0;
>  	}
> -	len += snprintf(buf + len, bufLen - len,
> +	len += scnprintf(buf + len, bufLen - len,
>  			"%03d: %1d%1d%1d%1d%02d%1d%1d%1d%1d",
>  			gpio,
>  			pinmux,
> @@ -625,10 +625,10 @@ ssize_t mtk_pctrl_show_one_pin(struct mtk_pinctrl *hw,
>  			pullup);
>  
>  	if (r1 != -1) {
> -		len += snprintf(buf + len, bufLen - len, " (%1d %1d)\n",
> +		len += scnprintf(buf + len, bufLen - len, " (%1d %1d)\n",
>  			r1, r0);
>  	} else {
> -		len += snprintf(buf + len, bufLen - len, "\n");
> +		len += scnprintf(buf + len, bufLen - len, "\n");
>  	}
>  
>  	return len;
> -- 
> 2.16.4
> 

  reply	other threads:[~2020-03-19 15:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11  9:06 [PATCH] pinctrl: mediatek: Use scnprintf() for avoiding potential buffer overflow Takashi Iwai
2020-03-19 15:53 ` Takashi Iwai [this message]
2020-03-27 10:31 ` Linus Walleij

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=s5hblosuyrl.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=sean.wang@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).