Re: [PATCH v8 4/5] treewide: Switch memcpy() users of 'task->comm' to a more safer implementation

From: Steven Rostedt
Date: Thu Aug 21 2025 - 12:47:51 EST


On Thu, 21 Aug 2025 15:51:51 +0530
Bhupesh <bhupesh@xxxxxxxxxx> wrote:

> +static __always_inline void
> + __cstr_array_copy(char *dst, const char *src,
> + __kernel_size_t size)
> +{
> + memcpy(dst, src, size);
> + dst[size] = 0;

Shouldn't this be: dst[size - 1] = 0;

?

Perhaps also add:

BUILD_BUG_ON(size == 0);

-- Steve

> +}
> +