On Thu, Dec 19, 2024 at 02:49:55PM -0800, Stephen Hemminger wrote: > 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)); >
Acked-by: Bruce Richardson <bruce.richard...@intel.com>