[libvirt] [PATCH v2] qemu: Check the unsigned integer overflow
Eric Blake
eblake at redhat.com
Tue Mar 15 14:51:26 UTC 2011
On 03/15/2011 04:51 AM, Daniel P. Berrange wrote:
>>> @@ -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,
>>
>> Wrong error. That's a user-supplied value, so it's not an internal
>> error. Better would be VIR_ERR_INVALID_ARG.
>
> No, INVALID_ARG should rarely be used - it indicates that a
> parameter to a method was incorrect. Using it for this will
> give horrible error messages. Better to use CONFIG_UNSUPPORTED
> for any semantic XML error.
Oh, sorry about that. As penance, I'm pushing the following under the
trivial rule:
From 30a50fc3b03cafc063df6ee0adb07487db12ba0b Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake at redhat.com>
Date: Tue, 15 Mar 2011 08:49:04 -0600
Subject: [PATCH] qemu: use more appropriate error
Fixes bug in commit acacced
* src/qemu/qemu_command.c (qemuBuildCommandLine):
s/INVALID_ARG/CONFIG_UNSUPPORTED/.
Reported by Daniel P. Berrange.
---
src/qemu/qemu_command.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c63de09..c9b9850 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1935,7 +1935,7 @@ qemuBuildVideoDevStr(virDomainVideoDefPtr video,
if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
if (video->vram > (UINT_MAX / 1024)) {
- qemuReportError(VIR_ERR_INVALID_ARG,
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("value for 'vram' must be less than '%u'"),
UINT_MAX / 1024);
goto error;
@@ -4050,7 +4050,7 @@ qemuBuildCommandLine(virConnectPtr conn,
if (def->videos[0]->vram &&
qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
if (def->videos[0]->vram > (UINT_MAX / 1024)) {
- qemuReportError(VIR_ERR_INVALID_ARG,
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("value for 'vram' must be
less than '%u'"),
UINT_MAX / 1024);
goto error;
--
1.7.4
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110315/8ad6bfba/attachment-0001.sig>
More information about the libvir-list
mailing list