Re: [PATCH] staging: fbtft: prefer scnprintf over sprintf in fbtft-core.c

From: Dan Carpenter

Date: Wed Aug 19 2026 - 14:25:26 EST


On Wed, Aug 19, 2026 at 06:44:44PM +0200, Tomasz Unger wrote:
> Using sprintf has potential for buffer overflows if the formatted
> string exceeds the destination buffer size. Replace it with
> scnprintf, passing sizeof() of the fixed-size stack buffers
> (text1[50] and text2[50]) so the write is always bounded.
>
> In practice an overflow is very unlikely here: text1 only needs

I don't have a problem with the patch, because I think making the
code easy to audit is helpful. However, change "unlikely" to
"impossible".

18446744073709551616 KiB buffer memory
123456789 123456789 123456789 1234567890

spi-4294967296.-4294967296 at -4294967296 MHz
123456789 123456789 123456789 123456789 1234567890

The other thing is that scnprintf() is only for if we care about
the return. Otherwise default to snprintf(). It's just a more
traditional choice.

regards,
dan carpenter