[PATCH v2] mtd: sm_ftl: replace strncpy with memcpy
Richard Weinberger
richard at nod.at
Mon Sep 8 02:04:20 PDT 2025
----- Ursprüngliche Mail -----
> Von: "Miquel Raynal" <miquel.raynal at bootlin.com>
> An: "Rahul Kumar" <rk0006818 at 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
More information about the linux-mtd
mailing list