mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
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:
parent
b82cf9e49c
commit
aabe047f8b
|
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user