public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eli Billauer <eli.billauer@gmail.com>
To: Thorsten Blum <thorsten.blum@linux.dev>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] char: xillybus: use strscpy() in init_chrdev
Date: Tue, 28 Apr 2026 10:37:49 +0200	[thread overview]
Message-ID: <b23eb57b-ce80-5f39-08a4-9dfddc7f3d14@outbound.gmail.com> (raw)
In-Reply-To: <20260427173730.418592-3-thorsten.blum@linux.dev>

Hello,

On 27/04/2026 19:37, Thorsten Blum wrote:

>   	if (!enumerate)
> -		snprintf(unit->name, UNITNAMELEN, "%s", prefix);
> +		strscpy(unit->name, prefix);
>   
>   	for (i = 0; enumerate; i++) {
>   		snprintf(unit->name, UNITNAMELEN, "%s_%02d",

snprintf() is used deliberately for code clarity: It makes a simple 
visual contrast with the use of snprintf() three rows below. As this 
call takes place only once for each physical hardware device handled by 
the driver, the advantage in optimizing this function call is negligible.

And even though it's formally OK to use strscpy() with two arguments, 
and let the compilation machinery find out the length of the char array, 
I have to admit that it gives me the chills. Buffer overflow and that.

So overall, I can't say I'm very fond of this patch. Thanks for the 
effort nevertheless.

Regards,
    Eli

  reply	other threads:[~2026-04-28  8:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 17:37 [PATCH] char: xillybus: use strscpy() in init_chrdev Thorsten Blum
2026-04-28  8:37 ` Eli Billauer [this message]
2026-04-28  8:55   ` Thorsten Blum
2026-04-28  9:05     ` Eli Billauer

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=b23eb57b-ce80-5f39-08a4-9dfddc7f3d14@outbound.gmail.com \
    --to=eli.billauer@gmail.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thorsten.blum@linux.dev \
    /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