mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
conf: fix integer overflow in virDomainControllerDefParseXML
Multiplication results in integer overflow. Thus, replace it with ULLONG_MAX and change def->opts.pciopts.pcihole64size type to ULL. Update variable usage according to new type. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Egor Makrushin <emakrushin@astralinux.ru> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
49f1406de8
commit
c3a8d04980
@ -8523,7 +8523,7 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
|
||||
unsigned long long bytes;
|
||||
if ((rc = virParseScaledValue("./pcihole64", NULL,
|
||||
ctxt, &bytes, 1024,
|
||||
1024ULL * ULONG_MAX, false)) < 0)
|
||||
ULLONG_MAX, false)) < 0)
|
||||
return NULL;
|
||||
|
||||
if (rc == 1)
|
||||
@ -23123,8 +23123,8 @@ virDomainControllerDefFormat(virBuffer *buf,
|
||||
|
||||
if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
|
||||
def->opts.pciopts.pcihole64) {
|
||||
virBufferAsprintf(&childBuf, "<pcihole64 unit='KiB'>%lu</"
|
||||
"pcihole64>\n", def->opts.pciopts.pcihole64size);
|
||||
virBufferAsprintf(&childBuf, "<pcihole64 unit='KiB'>%llu</pcihole64>\n",
|
||||
def->opts.pciopts.pcihole64size);
|
||||
}
|
||||
|
||||
virXMLFormatElement(buf, "controller", &attrBuf, &childBuf);
|
||||
|
@ -707,7 +707,7 @@ struct _virDomainVirtioSerialOpts {
|
||||
|
||||
struct _virDomainPCIControllerOpts {
|
||||
bool pcihole64;
|
||||
unsigned long pcihole64size;
|
||||
unsigned long long pcihole64size;
|
||||
|
||||
/* the exact controller name is in the "model" subelement, e.g.:
|
||||
* <controller type='pci' model='pcie-root-port'>
|
||||
|
@ -6211,7 +6211,7 @@ qemuBuildGlobalControllerCommandLine(virCommand *cmd,
|
||||
}
|
||||
|
||||
virCommandAddArg(cmd, "-global");
|
||||
virCommandAddArgFormat(cmd, "%s.pci-hole64-size=%luK", hoststr,
|
||||
virCommandAddArgFormat(cmd, "%s.pci-hole64-size=%lluK", hoststr,
|
||||
cont->opts.pciopts.pcihole64size);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user