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

On Tue, Apr 28, 2026 at 10:37:49AM +0200, Eli Billauer wrote:
> 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.

You probably mean strcpy()? strscpy() is safe regarding buffer overflow.

  reply	other threads:[~2026-04-28  8:56 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
2026-04-28  8:55   ` Thorsten Blum [this message]
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=afB2H9bRH2fAr9vc@linux.dev \
    --to=thorsten.blum@linux.dev \
    --cc=arnd@arndb.de \
    --cc=eli.billauer@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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