Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power: supply: test-power: use strscpy() 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: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Xu Panda and committed by
Sebastian Reichel
3639dbd7 e2b018cb

+1 -2
+1 -2
drivers/power/supply/test_power.c
··· 306 306 char buf[MAX_KEYLENGTH]; 307 307 int cr; 308 308 309 - strncpy(buf, key, MAX_KEYLENGTH); 310 - buf[MAX_KEYLENGTH-1] = '\0'; 309 + strscpy(buf, key, MAX_KEYLENGTH); 311 310 312 311 cr = strnlen(buf, MAX_KEYLENGTH) - 1; 313 312 if (cr < 0)