Re: [PATCH] [next] ARM: Replace snprintf() with the safer scnprintf() variant

From: Russell King (Oracle)
Date: Fri Oct 04 2024 - 05:10:25 EST


On Fri, Oct 04, 2024 at 03:59:30PM +1300, Paulo Miguel Almeida 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, basically, it's unsafe to use the result of (v)snprintf(). So why
do we need to change locations that do not use the result?

This patch is mere noise. Sorry, I won't be applying it.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!