mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemu: Check the unsigned integer overflow
As perhaps other hypervisor drivers use different capacity units, do the checking in qemu driver instead of in conf/domain_conf.c.
This commit is contained in:
parent
9bfde34661
commit
acacced812
@ -1934,6 +1934,13 @@ qemuBuildVideoDevStr(virDomainVideoDefPtr video,
|
|||||||
virBufferVSprintf(&buf, ",id=%s", video->info.alias);
|
virBufferVSprintf(&buf, ",id=%s", video->info.alias);
|
||||||
|
|
||||||
if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
|
if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
|
||||||
|
if (video->vram > (UINT_MAX / 1024)) {
|
||||||
|
qemuReportError(VIR_ERR_INVALID_ARG,
|
||||||
|
_("value for 'vram' must be less than '%u'"),
|
||||||
|
UINT_MAX / 1024);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
/* QEMU accepts bytes for vram_size. */
|
/* QEMU accepts bytes for vram_size. */
|
||||||
virBufferVSprintf(&buf, ",vram_size=%u", video->vram * 1024);
|
virBufferVSprintf(&buf, ",vram_size=%u", video->vram * 1024);
|
||||||
}
|
}
|
||||||
@ -4042,7 +4049,15 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
|
if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
|
||||||
if (def->videos[0]->vram &&
|
if (def->videos[0]->vram &&
|
||||||
qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||||
|
if (def->videos[0]->vram > (UINT_MAX / 1024)) {
|
||||||
|
qemuReportError(VIR_ERR_INVALID_ARG,
|
||||||
|
_("value for 'vram' must be less than '%u'"),
|
||||||
|
UINT_MAX / 1024);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
virCommandAddArg(cmd, "-global");
|
virCommandAddArg(cmd, "-global");
|
||||||
|
|
||||||
if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL_VGA))
|
if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL_VGA))
|
||||||
virCommandAddArgFormat(cmd, "qxl-vga.vram_size=%u",
|
virCommandAddArgFormat(cmd, "qxl-vga.vram_size=%u",
|
||||||
def->videos[0]->vram * 1024);
|
def->videos[0]->vram * 1024);
|
||||||
|
Loading…
Reference in New Issue
Block a user