Skip to content

Commit 7ddf005

Browse files
Xu Pandaingomolnar
authored andcommitted
x86/mce/dev-mcelog: use strscpy() to instead of strncpy()
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> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Tony Luck <tony.luck@intel.com> Link: https://lore.kernel.org/r/202212031419324523731@zte.com.cn
1 parent bd4edba commit 7ddf005

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

arch/x86/kernel/cpu/mce/dev-mcelog.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ static ssize_t set_trigger(struct device *s, struct device_attribute *attr,
105105
{
106106
char *p;
107107

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

112111
if (p)

0 commit comments

Comments
 (0)