Re: [PATCH 6/6] exec: open code copy_string_kernel
From: Matthew Wilcox
Date: Mon Apr 06 2020 - 08:10:39 EST
On Mon, Apr 06, 2020 at 02:03:12PM +0200, Christoph Hellwig wrote:
> + int len = strnlen(arg, MAX_ARG_STRLEN) + 1 /* terminating null */;
If you end up doing another version of this, it's a terminating NUL, not null.
I almost wonder if we shouldn't have
#define TERMINATING_NUL 1
in kernel.h.
int len = strnlen(arg, MAX_ARG_STRLEN) + TERMINATING_NUL;
has a certain appeal. There's the risk people might misuse it though ...
str[end] = TERMINATING_NUL;
so probably not a good idea.