From a290d7c4f50270387e90091524e307c4dea88bd5 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Tue, 16 Aug 2016 12:37:24 +0200 Subject: [PATCH] Fix coverity issues in vhost-user code, fixes VPP-189 Change-Id: Ief95aac5d4451f411dbed8050528708c0b1b7732 Signed-off-by: Damjan Marion --- vnet/vnet/devices/virtio/vhost-user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vnet/vnet/devices/virtio/vhost-user.c b/vnet/vnet/devices/virtio/vhost-user.c index 7dc7d0ebadf..dca60f14c67 100644 --- a/vnet/vnet/devices/virtio/vhost-user.c +++ b/vnet/vnet/devices/virtio/vhost-user.c @@ -296,6 +296,9 @@ static clib_error_t * vhost_user_socket_read (unix_file_t * uf) memset(&mh, 0, sizeof(mh)); memset(control, 0, sizeof(control)); + for (i=0; i < VHOST_MEMORY_MAX_NREGIONS; i++) + fds[i] = -1; + /* set the payload */ iov[0].iov_base = (void *) &msg; iov[0].iov_len = VHOST_USER_MSG_HDR_SZ; @@ -1498,7 +1501,7 @@ static int vhost_user_init_server_sock(const char * sock_filename, int *sockfd) } un.sun_family = AF_UNIX; - strcpy((char *) un.sun_path, (char *) sock_filename); + strncpy((char *) un.sun_path, (char *) sock_filename, sizeof(un.sun_path) - 1); /* remove if exists */ unlink( (char *) sock_filename); -- 2.16.6