Re: [PATCH 3/6] string: Introduce strtostr() for safe and performance string copies

From: Linus Torvalds

Date: Tue May 19 2026 - 16:44:16 EST


On Mon, 18 May 2026 at 09:37, André Almeida <andrealmeid@xxxxxxxxxx> wrote:
>
> The problem is that as I'm expanding current->comm, the source buffer
> might be bigger than destination, and when we truncate the string, it
> won't have the termination NUL byte. So we need an extra dest[len-1] =
> \0 after the memcpy.

What's wrong with just using strscpy() with 'len' being min(srcsize,dstsize)?

Linus