From c85a996d4a43f4a9f8f7e1506198cc1bfd015e2f Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 9 May 2019 22:42:23 +0000 Subject: [PATCH] MFC 334272: bhyve: guarantee NUL termination Use strlcpy to guarantee NUL termination of the path to a virtio console socket. --- usr.sbin/bhyve/pci_virtio_console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index 788f0a9526a..b6f9c8f3cc7 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -291,7 +291,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); - strncpy(sun.sun_path, basename((char *)path), sizeof(sun.sun_path)); + strlcpy(sun.sun_path, basename((char *)path), sizeof(sun.sun_path)); if (bindat(fd, s, (struct sockaddr *)&sun, sun.sun_len) < 0) { error = -1; -- 2.45.0