ipmi/watchdog: use strscpy() to instead of strncpy()
authoryang.yang29@zte.com.cn <yang.yang29@zte.com.cn>
Mon, 5 Dec 2022 11:36:40 +0000 (19:36 +0800)
committerCorey Minyard <cminyard@mvista.com>
Mon, 5 Dec 2022 12:50:09 +0000 (06:50 -0600)
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>
Message-Id: <202212051936400309332@zte.com.cn>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
drivers/char/ipmi/ipmi_watchdog.c

index 47365150e43106e2a6647ecf4ec03d34732b6293..0d4a8dcacfd4b422210a716de97fdef3750e29fa 100644 (file)
@@ -213,8 +213,7 @@ static int set_param_str(const char *val, const struct kernel_param *kp)
        char       valcp[16];
        char       *s;
 
-       strncpy(valcp, val, 15);
-       valcp[15] = '\0';
+       strscpy(valcp, val, 16);
 
        s = strstrip(valcp);