[PATCH] gcov: use strscpy() instead of strcpy() in init_node()
From: Hrushiraj Gandhi
Date: Mon Aug 31 2026 - 14:11:52 EST
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.
Signed-off-by: Hrushiraj Gandhi <hrushirajg23@xxxxxxxxx>
---
kernel/gcov/fs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/gcov/fs.c b/kernel/gcov/fs.c
index 1d19b1be207a..764918570de1 100644
--- a/kernel/gcov/fs.c
+++ b/kernel/gcov/fs.c
@@ -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);
}
/*