gcov: use strscpy() instead of strcpy() in init_node()

node->name is a flexible array member sized to exactly strlen(name) + 1
bytes at allocation time in new_node(), so this copy can never actually
overflow.  Still, prefer the bounded strscpy() over strcpy() on general
principle; pass the same strlen(name) + 1 bound the allocation used, since
sizeof() cannot be applied to a flexible array member.

No functional change.

Link: https://lore.kernel.org/20260831144953.324441-1-hrushirajg23@gmail.com
Signed-off-by: Hrushiraj Gandhi <hrushirajg23@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Bradley Morgan <brads@mainlining.org>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
This commit is contained in:
Hrushiraj Gandhi 2026-08-31 20:19:53 +05:30 committed by Andrew Morton
parent b82cf9e49c
commit aabe047f8b

View File

@ -529,7 +529,7 @@ static void init_node(struct gcov_node *node, struct gcov_info *info,
}
node->parent = parent;
if (name)
strcpy(node->name, name);
strscpy(node->name, name, strlen(name) + 1);
}
/*