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
This commit is contained in:
parent
47d6116239
commit
5d805962ca
@ -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);
|
||||
|
@ -3152,7 +3152,7 @@ pci_nvme_read(struct vmctx *ctx __unused, int vcpu __unused,
|
||||
static int
|
||||
pci_nvme_parse_config(struct pci_nvme_softc *sc, nvlist_t *nvl)
|
||||
{
|
||||
char bident[sizeof("XX:X:X")];
|
||||
char bident[sizeof("XXX:XXX")];
|
||||
const char *value;
|
||||
uint32_t sectsz;
|
||||
|
||||
@ -3226,7 +3226,7 @@ pci_nvme_parse_config(struct pci_nvme_softc *sc, nvlist_t *nvl)
|
||||
return (-1);
|
||||
}
|
||||
} else {
|
||||
snprintf(bident, sizeof(bident), "%d:%d",
|
||||
snprintf(bident, sizeof(bident), "%u:%u",
|
||||
sc->nsc_pi->pi_slot, sc->nsc_pi->pi_func);
|
||||
sc->nvstore.ctx = blockif_open(nvl, bident);
|
||||
if (sc->nvstore.ctx == NULL) {
|
||||
|
@ -453,7 +453,7 @@ static int
|
||||
pci_vtblk_init(struct vmctx *ctx __unused, struct pci_devinst *pi,
|
||||
nvlist_t *nvl)
|
||||
{
|
||||
char bident[sizeof("XX:X:X")];
|
||||
char bident[sizeof("XXX:XXX")];
|
||||
struct blockif_ctxt *bctxt;
|
||||
const char *path, *serial;
|
||||
MD5_CTX mdctx;
|
||||
@ -465,7 +465,7 @@ pci_vtblk_init(struct vmctx *ctx __unused, struct pci_devinst *pi,
|
||||
/*
|
||||
* The supplied backing file has to exist
|
||||
*/
|
||||
snprintf(bident, sizeof(bident), "%d:%d", pi->pi_slot, pi->pi_func);
|
||||
snprintf(bident, sizeof(bident), "%u:%u", pi->pi_slot, pi->pi_func);
|
||||
bctxt = blockif_open(nvl, bident);
|
||||
if (bctxt == NULL) {
|
||||
perror("Could not open backing file");
|
||||
|
Loading…
Reference in New Issue
Block a user