|
|
db03f0 |
From 78eb8b60d59662271c4a9a1be8c9002ee84dc8cf Mon Sep 17 00:00:00 2001
|
|
|
db03f0 |
From: Richard W.M. Jones <rjones@redhat.com>
|
|
|
db03f0 |
Date: Wed, 25 May 2011 17:52:26 +0100
|
|
|
db03f0 |
Subject: [PATCH] json: Avoid passing large positive 64 bit integers to QMP.
|
|
|
db03f0 |
|
|
|
db03f0 |
http://lists.gnu.org/archive/html/qemu-devel/2011-05/threads.html#02162
|
|
|
db03f0 |
|
|
|
db03f0 |
Currently, qemu silently clips any JSON integer in the range
|
|
|
db03f0 |
0x8000000000000000 - 0xffffffffffffffff (all numbers in this range
|
|
|
db03f0 |
will be clipped to 0x7fffffffffffffff == LLONG_MAX).
|
|
|
db03f0 |
|
|
|
db03f0 |
To avoid this, pass these as signed 64 bit integers in the QMP
|
|
|
db03f0 |
request.
|
|
|
db03f0 |
---
|
|
|
db03f0 |
src/qemu/qemu_monitor_json.c | 9 +++++++--
|
|
|
db03f0 |
1 files changed, 7 insertions(+), 2 deletions(-)
|
|
|
db03f0 |
|
|
|
db03f0 |
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
|
|
|
db03f0 |
index 2d8a390..bdd0dcb 100644
|
|
|
db03f0 |
--- a/src/qemu/qemu_monitor_json.c
|
|
|
db03f0 |
+++ b/src/qemu/qemu_monitor_json.c
|
|
|
db03f0 |
@@ -413,8 +413,13 @@ qemuMonitorJSONMakeCommand(const char *cmdname,
|
|
|
db03f0 |
ret = virJSONValueObjectAppendNumberLong(jargs, key, val);
|
|
|
db03f0 |
} break;
|
|
|
db03f0 |
case 'U': {
|
|
|
db03f0 |
- unsigned long long val = va_arg(args, unsigned long long);
|
|
|
db03f0 |
- ret = virJSONValueObjectAppendNumberUlong(jargs, key, val);
|
|
|
db03f0 |
+ /* qemu silently truncates numbers larger than LLONG_MAX,
|
|
|
db03f0 |
+ * so passing the full range of unsigned 64 bit integers
|
|
|
db03f0 |
+ * is not safe here. Pass them as signed 64 bit integers
|
|
|
db03f0 |
+ * instead.
|
|
|
db03f0 |
+ */
|
|
|
db03f0 |
+ long long val = va_arg(args, long long);
|
|
|
db03f0 |
+ ret = virJSONValueObjectAppendNumberLong(jargs, key, val);
|
|
|
db03f0 |
} break;
|
|
|
db03f0 |
case 'd': {
|
|
|
db03f0 |
double val = va_arg(args, double);
|
|
|
db03f0 |
--
|
|
|
db03f0 |
1.7.5.1
|
|
|
db03f0 |
|