mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-25 05:04:09 +08:00
liquidio: 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> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
94d30e8933
commit
f6b759f56d
@ -247,8 +247,7 @@ static const struct cvmx_bootmem_named_block_desc
|
||||
struct cvmx_bootmem_named_block_desc,
|
||||
size));
|
||||
|
||||
strncpy(desc->name, name, sizeof(desc->name));
|
||||
desc->name[sizeof(desc->name) - 1] = 0;
|
||||
strscpy(desc->name, name, sizeof(desc->name));
|
||||
return &oct->bootmem_named_block_desc;
|
||||
} else {
|
||||
return NULL;
|
||||
@ -471,8 +470,8 @@ static void output_console_line(struct octeon_device *oct,
|
||||
if (line != &console_buffer[bytes_read]) {
|
||||
console_buffer[bytes_read] = '\0';
|
||||
len = strlen(console->leftover);
|
||||
strncpy(&console->leftover[len], line,
|
||||
sizeof(console->leftover) - len);
|
||||
strscpy(&console->leftover[len], line,
|
||||
sizeof(console->leftover) - len + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user