mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] bcachefs: replace deprecated strncpy with strscpy
@ 2024-11-13  7:42 Daniel Yang
  2024-11-14  2:21 ` Kent Overstreet
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Yang @ 2024-11-13  7:42 UTC (permalink / raw)
  To: Kent Overstreet, open list:BCACHEFS, open list; +Cc: Daniel Yang

The function strncpy is deprecated due to not guaranteeing the
destination buffer will be NULL-terminated. The recommended replacement
is to use strscpy().

Signed-off-by: Daniel Yang <danielyangkang@gmail.com>
---
 fs/bcachefs/btree_trans_commit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/bcachefs/btree_trans_commit.c b/fs/bcachefs/btree_trans_commit.c
index 9bf471fa4..37e98695b 100644
--- a/fs/bcachefs/btree_trans_commit.c
+++ b/fs/bcachefs/btree_trans_commit.c
@@ -364,7 +364,7 @@ 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));
+	strscpy(l->d, trans->fn, JSET_ENTRY_LOG_U64s * sizeof(u64));
 }
 
 static inline int btree_key_can_insert(struct btree_trans *trans,
-- 
2.39.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-14  7:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-13  7:42 [PATCH] bcachefs: replace deprecated strncpy with strscpy Daniel Yang
2024-11-14  2:21 ` Kent Overstreet
2024-11-14  7:55   ` Daniel Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®