From: Dan Carpenter <dan.carpenter@linaro.org>
To: tomasz.unger@yahoo.pl
Cc: Hans de Goede <hansg@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Andy Shevchenko <andy@kernel.org>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: atomisp: replace sprintf with strscpy
Date: Thu, 26 Feb 2026 10:10:09 +0300 [thread overview]
Message-ID: <aZ_x0QmR66q8R4MZ@stanley.mountain> (raw)
In-Reply-To: <20260225204548.168092-1-tomasz.unger@yahoo.pl>
On Wed, Feb 25, 2026 at 09:45:48PM +0100, tomasz.unger@yahoo.pl wrote:
> From: Tomasz Unger <tomasz.unger@yahoo.pl>
>
> Replace deprecated sprintf() with strscpy() which is the preferred
> kernel API for string copying. strscpy() is safer as it guarantees
> null-termination and prevents potential buffer overflows.
>
Technically sprintf() also guarantees NUL termination. :P
When you're writing a commit like this I want the first or second
sentence to say "This patch does not affect run-time because sd->name
is a 52 character buffer." I would prefer to avoid any talk about
"potential buffer overflows." It's the same as me claiming that I am
potentially an NBA star. Something like this:
I am doing an audit of calls to sprintf(). This code is fine
because we are copying 9 characters into a 52 character buffer.
But it would be cleaner to use strscpy() instead.
> Since sd->name is a fixed-size array, the destination buffer size
> is deduced automatically by the kernel-defined strscpy() macro,
> so no explicit size parameter is needed.
>
> Compiled and tested by loading atomisp.ko module successfully.
This information should go under the --- cut off line.
>
> Signed-off-by: Tomasz Unger <tomasz.unger@yahoo.pl>
> ---
^^^
Here.
regards,
dan carpenter
prev parent reply other threads:[~2026-02-26 7:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260225204548.168092-1-tomasz.unger.ref@yahoo.pl>
2026-02-25 20:45 ` [PATCH] staging: atomisp: replace sprintf with strscpy tomasz.unger
2026-02-26 7:10 ` 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=aZ_x0QmR66q8R4MZ@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=andy@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--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