[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CACRpkdbvncOsbG2W3vJJz8N4mH8XCqyf_Ny1_hsLwK4P+7x1Cw@mail.gmail.com>
Date: Thu, 30 Nov 2023 15:48:27 +0100
From: Linus Walleij <linus.walleij@...aro.org>
To: Lee Jones <lee@...nel.org>
Cc: linux-kernel@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Yuan-Hsin Chen <yhchen@...aday-tech.com>,
Feng-Hsin Chiang <john453@...aday-tech.com>,
Po-Yu Chuang <ratbert.chuang@...il.com>,
linux-usb@...r.kernel.org
Subject: Re: [PATCH 3/5] usb: fotg210-hcd: Replace snprintf() with the safer
scnprintf() variant
On Thu, Nov 30, 2023 at 11:55 AM Lee Jones <lee@...nel.org> wrote:
> There is a general misunderstanding amongst engineers that {v}snprintf()
> returns the length of the data *actually* encoded into the destination
> array. However, as per the C99 standard {v}snprintf() really returns
> the length of the data that *would have been* written if there were
> enough space for it. This misunderstanding has led to buffer-overruns
> in the past. It's generally considered safer to use the {v}scnprintf()
> variants in their place (or even sprintf() in simple cases). So let's
> do that.
>
> The uses in this file both seem to assume that data *has been* written!
>
> Link: https://lwn.net/Articles/69419/
> Link: https://github.com/KSPP/linux/issues/105
> Cc: Linus Walleij <linus.walleij@...aro.org>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Cc: Yuan-Hsin Chen <yhchen@...aday-tech.com>
> Cc: Feng-Hsin Chiang <john453@...aday-tech.com>
> Cc: Po-Yu Chuang <ratbert.chuang@...il.com>
> Cc: linux-usb@...r.kernel.org
> Signed-off-by: Lee Jones <lee@...nel.org>
Reviewed-by: Linus Walleij <linus.walleij@...aro.org>
Thanks for doing this Lee!
And as David points out it is even a bug fix at the same time.
Yours,
Linus Walleij
Powered by blists - more mailing lists