* [PATCH] media: rc: Use scnprintf() for avoiding potential buffer overflow
@ 2020-03-11 7:47 Takashi Iwai
2020-03-19 15:57 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2020-03-11 7:47 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: linux-media
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>
---
drivers/media/rc/nuvoton-cir.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index 5c2cd8d2d155..48a69bf23236 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -230,10 +230,10 @@ static ssize_t wakeup_data_show(struct device *dev,
for (i = 0; i < fifo_len; i++) {
duration = nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY);
duration = (duration & BUF_LEN_MASK) * SAMPLE_PERIOD;
- buf_len += snprintf(buf + buf_len, PAGE_SIZE - buf_len,
+ buf_len += scnprintf(buf + buf_len, PAGE_SIZE - buf_len,
"%d ", duration);
}
- buf_len += snprintf(buf + buf_len, PAGE_SIZE - buf_len, "\n");
+ buf_len += scnprintf(buf + buf_len, PAGE_SIZE - buf_len, "\n");
spin_unlock_irqrestore(&nvt->lock, flags);
--
2.16.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] media: rc: Use scnprintf() for avoiding potential buffer overflow
2020-03-11 7:47 [PATCH] media: rc: Use scnprintf() for avoiding potential buffer overflow Takashi Iwai
@ 2020-03-19 15:57 ` Takashi Iwai
2020-03-20 13:49 ` Sean Young
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2020-03-19 15:57 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: linux-media
On Wed, 11 Mar 2020 08:47:06 +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 changes are needed.
thanks,
Takashi
> ---
> drivers/media/rc/nuvoton-cir.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
> index 5c2cd8d2d155..48a69bf23236 100644
> --- a/drivers/media/rc/nuvoton-cir.c
> +++ b/drivers/media/rc/nuvoton-cir.c
> @@ -230,10 +230,10 @@ static ssize_t wakeup_data_show(struct device *dev,
> for (i = 0; i < fifo_len; i++) {
> duration = nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY);
> duration = (duration & BUF_LEN_MASK) * SAMPLE_PERIOD;
> - buf_len += snprintf(buf + buf_len, PAGE_SIZE - buf_len,
> + buf_len += scnprintf(buf + buf_len, PAGE_SIZE - buf_len,
> "%d ", duration);
> }
> - buf_len += snprintf(buf + buf_len, PAGE_SIZE - buf_len, "\n");
> + buf_len += scnprintf(buf + buf_len, PAGE_SIZE - buf_len, "\n");
>
> spin_unlock_irqrestore(&nvt->lock, flags);
>
> --
> 2.16.4
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: rc: Use scnprintf() for avoiding potential buffer overflow
2020-03-19 15:57 ` Takashi Iwai
@ 2020-03-20 13:49 ` Sean Young
0 siblings, 0 replies; 3+ messages in thread
From: Sean Young @ 2020-03-20 13:49 UTC (permalink / raw)
To: Takashi Iwai; +Cc: Mauro Carvalho Chehab, linux-media
On Thu, Mar 19, 2020 at 04:57:42PM +0100, Takashi Iwai wrote:
> On Wed, 11 Mar 2020 08:47:06 +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 changes are needed.
Thank you for your reminder. The changes look good, unfortunately they
missed the deadline for v5.7. I handle them after the next merge window.
Thanks,
Sean
>
>
> thanks,
>
> Takashi
>
> > ---
> > drivers/media/rc/nuvoton-cir.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
> > index 5c2cd8d2d155..48a69bf23236 100644
> > --- a/drivers/media/rc/nuvoton-cir.c
> > +++ b/drivers/media/rc/nuvoton-cir.c
> > @@ -230,10 +230,10 @@ static ssize_t wakeup_data_show(struct device *dev,
> > for (i = 0; i < fifo_len; i++) {
> > duration = nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY);
> > duration = (duration & BUF_LEN_MASK) * SAMPLE_PERIOD;
> > - buf_len += snprintf(buf + buf_len, PAGE_SIZE - buf_len,
> > + buf_len += scnprintf(buf + buf_len, PAGE_SIZE - buf_len,
> > "%d ", duration);
> > }
> > - buf_len += snprintf(buf + buf_len, PAGE_SIZE - buf_len, "\n");
> > + buf_len += scnprintf(buf + buf_len, PAGE_SIZE - buf_len, "\n");
> >
> > spin_unlock_irqrestore(&nvt->lock, flags);
> >
> > --
> > 2.16.4
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-20 13:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-11 7:47 [PATCH] media: rc: Use scnprintf() for avoiding potential buffer overflow Takashi Iwai
2020-03-19 15:57 ` Takashi Iwai
2020-03-20 13:49 ` Sean Young
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).