virtio_console: use strscpy to instead of strncpy()
Subsystems (2)
PATCH 1/1 virtio_console: use strscpy to instead of strncpy()
From: Xu Panda <[email protected]>
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]>
--- drivers/char/virtio_console.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/char/virtio_console.c +2 -3
@@ -1666,9 +1666,8 @@ static void handle_control_message(struct virtio_device *vdev, "Not enough space to store port name\n");break ; } -strncpy (port->name, buf->buf + buf->offset +sizeof (*cpkt), - name_size -1 ); - port->name[name_size -1 ] =0 ; +strscpy (port->name, buf->buf + buf->offset +sizeof (*cpkt), + name_size);/* * Since we only have one sysfs attribute, 'name',
Signature · 1 line
2.15.2