diff options
| author | Xu Panda <[email protected]> | 2022-12-03 14:19:32 +0800 |
|---|---|---|
| committer | Ingo Molnar <[email protected]> | 2023-01-07 11:47:35 +0100 |
| commit | 7ddf0050a21fdcc025c3cb1055fe3db60df1cd97 (patch) | |
| tree | 95a2b11a179a19cadef75c8d389aa9cbde43a728 | |
| parent | bd4edba2653aeef0119b7a945f07e58711343bf9 (diff) | |
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 <[email protected]>
Signed-off-by: Yang Yang <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
| -rw-r--r-- | arch/x86/kernel/cpu/mce/dev-mcelog.c | 3 |
1 files changed, 1 insertions, 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) |