[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 23/29] monitor: fail when 'i' type is greater than 3
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 23/29] monitor: fail when 'i' type is greater than 32-bit |
Date: |
Wed, 26 Aug 2009 14:05:46 -0300 |
The 'i' argument type is for 32-bit only and most handlers
will use an 'int' to store its value.
It's better to fail gracefully when the user enters a value
greater than 32-bit than to get subtle casting bugs.
Signed-off-by: Luiz Capitulino <address@hidden>
---
monitor.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/monitor.c b/monitor.c
index 68fbf34..2932f0b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2748,6 +2748,12 @@ static const mon_cmd_t *monitor_parse_command(Monitor
*mon,
}
if (get_expr(mon, &val, &p))
goto fail;
+ /* Check if 'i' is greater than 32-bit */
+ if ((c == 'i') && ((val >> 32) & 0xffffffff)) {
+ monitor_printf(mon, "\'%s\' has failed: ", cmdname);
+ monitor_printf(mon, "integer is for 32-bit values\n");
+ goto fail;
+ }
qdict_put(qdict, key, qint_from_int(val));
}
break;
--
1.6.4.1.184.g2e117
- [Qemu-devel] [PATCH 13/29] monitor: Port handler_4 to use QDict, (continued)
- [Qemu-devel] [PATCH 13/29] monitor: Port handler_4 to use QDict, Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 14/29] monitor: Port handler_5 to use QDict, Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 15/29] monitor: Port handler_6 to use QDict, Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 16/29] monitor: Port handler_7 to use QDict, Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 17/29] monitor: Drop handler_8 and handler_9, Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 18/29] monitor: Port handler_10 to use QDict, Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 19/29] monitor: Split monitor_handle_command(), Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 20/29] monitor: Drop unused macros, Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 21/29] monitor: Drop str_allocated[], Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 22/29] monitor: Drop args[] handling code, Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 23/29] monitor: fail when 'i' type is greater than 32-bit,
Luiz Capitulino <=
- [Qemu-devel] [PATCH 24/29] monitor: Update supported types documentation, Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 25/29] Add check support, Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 26/29] Introduce QInt unit-tests, Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 27/29] Introduce QString unit-tests, Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 28/29] Introduce QDict test data file, Luiz Capitulino, 2009/08/26
- [Qemu-devel] [PATCH 29/29] Introduce QDict unit-tests, Luiz Capitulino, 2009/08/26