From: Roxana Nicolescu Date: Thu, 27 Mar 2025 14:50:05 +0000 (+0000) Subject: bcachefs: replace strncpy() with memcpy_and_pad in journal_transaction_name X-Git-Tag: v6.16-rc1~211^2~212 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e2caf82ce958d1fae96a6d6ba23ea9e80c597b4;p=thirdparty%2Fkernel%2Fstable.git bcachefs: replace strncpy() with memcpy_and_pad in journal_transaction_name Strncpy is now deprecated. The buffer destination is not required to be NULL-terminated, but we also want to zero out the rest of the buffer as it is already done in other places. Link: https://github.com/KSPP/linux/issues/90 Signed-off-by: Roxana Nicolescu Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/btree_trans_commit.c b/fs/bcachefs/btree_trans_commit.c index 7d7e52ddde02a..4297d8b5edddf 100644 --- a/fs/bcachefs/btree_trans_commit.c +++ b/fs/bcachefs/btree_trans_commit.c @@ -20,6 +20,7 @@ #include "snapshot.h" #include +#include static const char * const trans_commit_flags_strs[] = { #define x(n, ...) #n, @@ -366,7 +367,8 @@ static noinline void journal_transaction_name(struct btree_trans *trans) struct jset_entry_log *l = container_of(entry, struct jset_entry_log, entry); - strncpy(l->d, trans->fn, JSET_ENTRY_LOG_U64s * sizeof(u64)); + memcpy_and_pad(l->d, JSET_ENTRY_LOG_U64s * sizeof(u64), + trans->fn, strlen(trans->fn), 0); } static inline int btree_key_can_insert(struct btree_trans *trans,