public inbox for linux-edac@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next] x86/mce/dev-mcelog: use strscpy() to instead of strncpy()
@ 2022-12-03  6:19 yang.yang29
  2022-12-03 22:21 ` Luck, Tony
  2022-12-14 20:54 ` Ricardo Neri
  0 siblings, 2 replies; 5+ messages in thread
From: yang.yang29 @ 2022-12-03  6:19 UTC (permalink / raw)
  To: tony.luck
  Cc: bp, tglx, mingo, dave.hansen, x86, hpa, linux-edac, linux-kernel,
	xu.panda, yang.yang29

From: Xu Panda <xu.panda@zte.com.cn>

The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL terminated strings.

Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com>
---
 arch/x86/kernel/cpu/mce/dev-mcelog.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/mce/dev-mcelog.c b/arch/x86/kernel/cpu/mce/dev-mcelog.c
index 100fbeebdc72..a05ac0716ecf 100644
--- a/arch/x86/kernel/cpu/mce/dev-mcelog.c
+++ b/arch/x86/kernel/cpu/mce/dev-mcelog.c
@@ -105,8 +105,7 @@ static ssize_t set_trigger(struct device *s, struct device_attribute *attr,
 {
 	char *p;

-	strncpy(mce_helper, buf, sizeof(mce_helper));
-	mce_helper[sizeof(mce_helper)-1] = 0;
+	strscpy(mce_helper, buf, sizeof(mce_helper));
 	p = strchr(mce_helper, '\n');

 	if (p)
-- 
2.15.2

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

end of thread, other threads:[~2022-12-14 22:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-03  6:19 [PATCH linux-next] x86/mce/dev-mcelog: use strscpy() to instead of strncpy() yang.yang29
2022-12-03 22:21 ` Luck, Tony
2022-12-14 20:54 ` Ricardo Neri
2022-12-14 21:29   ` Luck, Tony
2022-12-14 22:54     ` Ricardo Neri

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