[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V4 05/19] monitor: check return value of qemu_find_n
From: |
Jason Wang |
Subject: |
[Qemu-devel] [PATCH V4 05/19] monitor: check return value of qemu_find_net_clients_except() |
Date: |
Wed, 18 Mar 2015 17:34:55 +0800 |
qemu_find_net_clients_except() may return a value which is greater
than the size of array we provided. So we should check this value
before using it, otherwise this may cause unexpected memory access.
This patch fixes the net related command completion when we have a
virtio-net nic with more than 255 queues.
Cc: Luiz Capitulino <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
---
monitor.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/monitor.c b/monitor.c
index 07dfed0..3c0abfd 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4480,7 +4480,7 @@ void set_link_completion(ReadLineState *rs, int nb_args,
const char *str)
count = qemu_find_net_clients_except(NULL, ncs,
NET_CLIENT_OPTIONS_KIND_NONE,
MAX_QUEUE_NUM);
- for (i = 0; i < count; i++) {
+ for (i = 0; i < MIN(count, MAX_QUEUE_NUM); i++) {
const char *name = ncs[i]->name;
if (!strncmp(str, name, len)) {
readline_add_completion(rs, name);
@@ -4505,7 +4505,7 @@ void netdev_del_completion(ReadLineState *rs, int
nb_args, const char *str)
readline_set_completion_index(rs, len);
count = qemu_find_net_clients_except(NULL, ncs,
NET_CLIENT_OPTIONS_KIND_NIC,
MAX_QUEUE_NUM);
- for (i = 0; i < count; i++) {
+ for (i = 0; i < MIN(count, MAX_QUEUE_NUM); i++) {
QemuOpts *opts;
const char *name = ncs[i]->name;
if (strncmp(str, name, len)) {
@@ -4579,7 +4579,7 @@ void host_net_remove_completion(ReadLineState *rs, int
nb_args, const char *str)
count = qemu_find_net_clients_except(NULL, ncs,
NET_CLIENT_OPTIONS_KIND_NONE,
MAX_QUEUE_NUM);
- for (i = 0; i < count; i++) {
+ for (i = 0; i < MIN(count, MAX_QUEUE_NUM); i++) {
int id;
char name[16];
@@ -4596,7 +4596,7 @@ void host_net_remove_completion(ReadLineState *rs, int
nb_args, const char *str)
count = qemu_find_net_clients_except(NULL, ncs,
NET_CLIENT_OPTIONS_KIND_NIC,
MAX_QUEUE_NUM);
- for (i = 0; i < count; i++) {
+ for (i = 0; i < MIN(count, MAX_QUEUE_NUM); i++) {
int id;
const char *name;
--
2.1.0
- [Qemu-devel] [PATCH V4 00/19] Support more virtio queues, Jason Wang, 2015/03/18
- [Qemu-devel] [PATCH V4 01/19] pc: add 2.4 machine types, Jason Wang, 2015/03/18
- [Qemu-devel] [PATCH V4 02/19] spapr: add machine type specific instance init function, Jason Wang, 2015/03/18
- [Qemu-devel] [PATCH V4 04/19] monitor: replace the magic number 255 with MAX_QUEUE_NUM, Jason Wang, 2015/03/18
- [Qemu-devel] [PATCH V4 03/19] ppc: spapr: add 2.4 machine type, Jason Wang, 2015/03/18
- [Qemu-devel] [PATCH V4 06/19] virtio-ccw: using VIRTIO_NO_VECTOR instead of 0 for invalid virtqueue, Jason Wang, 2015/03/18
[Qemu-devel] [PATCH V4 05/19] monitor: check return value of qemu_find_net_clients_except(),
Jason Wang <=
[Qemu-devel] [PATCH V4 08/19] virtio-net: fix the upper bound when trying to delete queues, Jason Wang, 2015/03/18
[Qemu-devel] [PATCH V4 07/19] virtio-net: validate backend queue numbers against bus limitation, Jason Wang, 2015/03/18
[Qemu-devel] [PATCH V4 10/19] virtio-ccw: introduce ccw specific queue limit, Jason Wang, 2015/03/18
[Qemu-devel] [PATCH V4 09/19] virito: introduce bus specific queue limit, Jason Wang, 2015/03/18