Skip to content

Commit 6380bf8

Browse files
tobluxpetrpavlu
authored andcommitted
module: Replace deprecated strncpy() with strscpy()
strncpy() is deprecated for NUL-terminated destination buffers; use strscpy() instead. The destination buffer ownername is only used with "%s" format strings and must therefore be NUL-terminated, but not NUL- padded. No functional changes intended. Link: KSPP#90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Link: https://lore.kernel.org/r/20250307113546.112237-2-thorsten.blum@linux.dev Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
1 parent 3690f4a commit 6380bf8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/module/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
11791179

11801180
getname:
11811181
/* We must make copy under the lock if we failed to get ref. */
1182-
strncpy(ownername, module_name(fsa.owner), MODULE_NAME_LEN);
1182+
strscpy(ownername, module_name(fsa.owner), MODULE_NAME_LEN);
11831183
unlock:
11841184
mutex_unlock(&module_mutex);
11851185
return fsa.sym;

0 commit comments

Comments
 (0)