public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Rahul Kumar <rk0006818@gmail.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	 linux-mtd <linux-mtd@lists.infradead.org>,
	 linux-kernel <linux-kernel@vger.kernel.org>,
	 linux-kernel-mentees@lists.linux.dev,
	 Shuah Khan <skhan@linuxfoundation.org>,
	 pratyush <pratyush@kernel.org>
Subject: Re: [PATCH v2] mtd: sm_ftl: replace strncpy with memcpy
Date: Mon, 8 Sep 2025 11:04:20 +0200 (CEST)	[thread overview]
Message-ID: <93578759.11447.1757322260340.JavaMail.zimbra@nod.at> (raw)
In-Reply-To: <87tt1djtot.fsf@bootlin.com>

----- Ursprüngliche Mail -----
> Von: "Miquel Raynal" <miquel.raynal@bootlin.com>
> An: "Rahul Kumar" <rk0006818@gmail.com>
>> -	strncpy(buf, sm_attr->data, sm_attr->len);
>> -	return sm_attr->len;
>> +	memcpy(buf, sm_attr->data, sm_attr->len);
>> +	buf[sm_attr->len] = '\0';
>> +	return sm_attr->len + 1;
> 
> Are we sure the buffer is always sm_attr->len + 1 long?

Can we please just stop messing with perfectly fine code?
I'm sick of the war on string functions.
First we had to replace everything with strncpy(), then strlcpy(),
then strscpy(), ...

Don't get me wrong, I'm all for hardening code paths where
strings are arbitrary input, but in many of these cases all strings
are no input or already sanitized.

Thanks,
//richard

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2025-09-08  9:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-08  7:01 [PATCH v2] mtd: sm_ftl: replace strncpy with memcpy Rahul Kumar
2025-09-08  7:21 ` Miquel Raynal
2025-09-08  9:04   ` Richard Weinberger [this message]
2025-09-09 11:45     ` Pratyush Yadav
2025-09-09 12:12       ` Rahul Kumar
2025-09-09 19:50         ` Richard Weinberger
2025-09-10  7:02           ` Rahul Kumar
2025-09-09 11:27 ` Pratyush Yadav

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=93578759.11447.1757322260340.JavaMail.zimbra@nod.at \
    --to=richard@nod.at \
    --cc=linux-kernel-mentees@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=pratyush@kernel.org \
    --cc=rk0006818@gmail.com \
    --cc=skhan@linuxfoundation.org \
    --cc=vigneshr@ti.com \
    /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