On Wed, Apr 03, 2019 at 02:16:20PM +0200, Philippe Mathieu-Daudé wrote: > Compiling with clang-8 fails with: > > CC util/qemu-sockets.o > util/qemu-sockets.c: In function 'unix_connect_saddr': > util/qemu-sockets.c:925:5: error: 'strncpy' specified bound 108 equals > destination size [-Werror=stringop-truncation] > strncpy(un.sun_path, saddr->path, sizeof(un.sun_path)); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > util/qemu-sockets.c: In function 'unix_listen_saddr': > util/qemu-sockets.c:880:5: error: 'strncpy' specified bound 108 equals > destination size [-Werror=stringop-truncation] > strncpy(un.sun_path, path, sizeof(un.sun_path)); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Per the unix socket manpage: > > UNIX(7) > > Pathname sockets > When binding a socket to a pathname, a few rules should be observed for > maximum portability and ease of coding: > * The pathname in sun_path should be null-terminated. > * The length of the pathname, including the terminating null byte, should > not exceed the size of sun_path. > > Reduce the length of the unix socket path by 1 to hold the NUL byte.
Note it just says "should", not "must" here. IOW, there is no requirement to NUL terminate and so we should not artifically require that at QEMU level either. If mgmt apps want to have NUL termination then they can just pass a shorter path to QEMU to start with. I've proposed the fix for the warning you mention here: https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg07759.html Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|