Some tools such as gcc address sanitizer will complain if strncpy is used to completely fill a string since it will not be null terminated. Since the previous code forced as null at end, use strlcpy() to get the same effect.
Signed-off-by: Stephen Hemminger <step...@networkplumber.org> --- lib/vhost/socket.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c index d29d15494c..f938189cc2 100644 --- a/lib/vhost/socket.c +++ b/lib/vhost/socket.c @@ -359,8 +359,7 @@ create_unix_socket(struct vhost_user_socket *vsocket) memset(un, 0, sizeof(*un)); un->sun_family = AF_UNIX; - strncpy(un->sun_path, vsocket->path, sizeof(un->sun_path)); - un->sun_path[sizeof(un->sun_path) - 1] = '\0'; + strlcpy(un->sun_path, vsocket->path, sizeof(un->sun_path)); vsocket->socket_fd = fd; return 0; -- 2.45.2