aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/bhyve/pci_ahci.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2022-11-29 01:09:15 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2022-11-29 01:09:15 +0000
commit5d805962ca9347bbf62750452c4c980decb94793 (patch)
treef308e11fad6a9587576c0ffc9d58273cff07bce7 /usr.sbin/bhyve/pci_ahci.c
parent47d61162396bac8a7320a6768f218b192dd19ee1 (diff)
downloadsrc-5d805962ca9347bbf62750452c4c980decb94793.tar.gz
src-5d805962ca9347bbf62750452c4c980decb94793.zip
bhyve: Avoid unlikely truncation of the blockif ident strings.
The ident string for NVMe and VirtIO block deivces do not contain the bus, and the various fields can potentially use up to three characters when printed as unsigned values (full range of uint8_t) even if not likely in practice. Reviewed by: corvink, chuck Differential Revision: https://reviews.freebsd.org/D37488
Diffstat (limited to 'usr.sbin/bhyve/pci_ahci.c')
-rw-r--r--usr.sbin/bhyve/pci_ahci.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.sbin/bhyve/pci_ahci.c b/usr.sbin/bhyve/pci_ahci.c
index 4571f4caeffb..09b996476774 100644
--- a/usr.sbin/bhyve/pci_ahci.c
+++ b/usr.sbin/bhyve/pci_ahci.c
@@ -2422,7 +2422,7 @@ pci_ahci_hd_legacy_config(nvlist_t *nvl, const char *opts)
static int
pci_ahci_init(struct vmctx *ctx __unused, struct pci_devinst *pi, nvlist_t *nvl)
{
- char bident[sizeof("XX:XX:XX")];
+ char bident[sizeof("XXX:XXX:XXX")];
char node_name[sizeof("XX")];
struct blockif_ctxt *bctxt;
struct pci_ahci_softc *sc;
@@ -2469,7 +2469,7 @@ pci_ahci_init(struct vmctx *ctx __unused, struct pci_devinst *pi, nvlist_t *nvl)
* Attempt to open the backing image. Use the PCI slot/func
* and the port number for the identifier string.
*/
- snprintf(bident, sizeof(bident), "%d:%d:%d", pi->pi_slot,
+ snprintf(bident, sizeof(bident), "%u:%u:%u", pi->pi_slot,
pi->pi_func, p);
bctxt = blockif_open(port_nvl, bident);