From: Dan Carpenter <error27@gmail.com>
To: Tomasz Unger <tomasz.unger@yahoo.pl>
Cc: Andy Shevchenko <andy@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: fbtft: prefer scnprintf over sprintf in fbtft-core.c
Date: Wed, 19 Aug 2026 21:16:32 +0300 [thread overview]
Message-ID: <aoXzALsRLqyqro8X@stanley.mountain> (raw)
In-Reply-To: <20260819-fbtft-core-scnprintf-v1-1-842c0603634c@yahoo.pl>
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
prev parent reply other threads:[~2026-08-19 18:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260819-fbtft-core-scnprintf-v1-1-842c0603634c.ref@yahoo.pl>
2026-08-19 16:44 ` [PATCH] staging: fbtft: prefer scnprintf over sprintf in fbtft-core.c Tomasz Unger
2026-08-19 17:06 ` Andy Shevchenko
2026-08-19 18:21 ` Dan Carpenter
2026-08-19 18:16 ` Dan Carpenter [this message]
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=aoXzALsRLqyqro8X@stanley.mountain \
--to=error27@gmail.com \
--cc=andy@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=tomasz.unger@yahoo.pl \
/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