]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
audit: Replace deprecated strcpy() with strscpy()
authorThorsten Blum <thorsten.blum@linux.dev>
Fri, 18 Jul 2025 20:37:34 +0000 (22:37 +0200)
committerPaul Moore <paul@paul-moore.com>
Mon, 11 Aug 2025 15:44:55 +0000 (11:44 -0400)
strcpy() is deprecated; use strscpy() instead.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Paul Moore <paul@paul-moore.com>
kernel/audit_tree.c

index b0eae2a3c895d80d5c88a73bbfc66a9dcabbb8ff..1605df0a171ea87e220b8d24ab4bbb2e6b039080 100644 (file)
@@ -93,8 +93,10 @@ static struct kmem_cache *audit_tree_mark_cachep __ro_after_init;
 static struct audit_tree *alloc_tree(const char *s)
 {
        struct audit_tree *tree;
+       size_t sz;
 
-       tree = kmalloc(struct_size(tree, pathname, strlen(s) + 1), GFP_KERNEL);
+       sz = strlen(s) + 1;
+       tree = kmalloc(struct_size(tree, pathname, sz), GFP_KERNEL);
        if (tree) {
                refcount_set(&tree->count, 1);
                tree->goner = 0;
@@ -103,7 +105,7 @@ static struct audit_tree *alloc_tree(const char *s)
                INIT_LIST_HEAD(&tree->list);
                INIT_LIST_HEAD(&tree->same_root);
                tree->root = NULL;
-               strcpy(tree->pathname, s);
+               strscpy(tree->pathname, s, sz);
        }
        return tree;
 }