[libvirt] [PATCH] qemu: Check the unsigned integer overflow

Osier Yang jyang at redhat.com
Wed Mar 9 08:27:55 UTC 2011


As perhaps other hypervisor drivers use different capacity units,
do the checking in qemu driver instead of in conf/domain_conf.c.
---
 src/qemu/qemu_command.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 198a4e2..42be6ee 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1933,6 +1933,13 @@ qemuBuildVideoDevStr(virDomainVideoDefPtr video,
     virBufferVSprintf(&buf, ",id=%s", video->info.alias);

     if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
+        if (video->vram > (UINT_MAX / 1024)) {
+            qemuReportError(VIR_ERR_INTERNAL_ERROR,
+                            _("value for 'vram' must be less than '%u'"),
+                            UINT_MAX / 1024);
+            goto error;
+        }
+
         /* QEMU accepts bytes for vram_size. */
         virBufferVSprintf(&buf, ",vram_size=%u", video->vram * 1024);
     }
--
1.7.4




More information about the libvir-list mailing list