bhyve: guarantee NUL termination

Use strlcpy to guarantee NUL termination of the path to a
virtio console socket.

Reported by:	Coverity
CID:		1362874
Sponsored by:	Dell EMC
This commit is contained in:
Eric van Gyzen 2018-05-28 03:09:09 +00:00
parent 054e6e1335
commit 8a114a66b5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334272

View File

@ -306,7 +306,7 @@ pci_vtcon_sock_add(struct pci_vtcon_softc *sc, const char *name,
sun.sun_family = AF_UNIX;
sun.sun_len = sizeof(struct sockaddr_un);
strcpy(pathcopy, path);
strncpy(sun.sun_path, basename(pathcopy), sizeof(sun.sun_path));
strlcpy(sun.sun_path, basename(pathcopy), sizeof(sun.sun_path));
free(pathcopy);
if (bindat(fd, s, (struct sockaddr *)&sun, sun.sun_len) < 0) {