mirror of
https://github.com/torvalds/linux.git
synced 2024-12-28 22:02:28 +00:00
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>
This commit is contained in:
parent
e2b018cb55
commit
3639dbd74e
@ -306,8 +306,7 @@ static int map_get_value(struct battery_property_map *map, const char *key,
|
||||
char buf[MAX_KEYLENGTH];
|
||||
int cr;
|
||||
|
||||
strncpy(buf, key, MAX_KEYLENGTH);
|
||||
buf[MAX_KEYLENGTH-1] = '\0';
|
||||
strscpy(buf, key, MAX_KEYLENGTH);
|
||||
|
||||
cr = strnlen(buf, MAX_KEYLENGTH) - 1;
|
||||
if (cr < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user