OSDN Git Service

ivshmem-client: check the number of vectors
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 23 Jun 2015 14:41:58 +0000 (16:41 +0200)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Sat, 24 Oct 2015 16:03:16 +0000 (18:03 +0200)
Check the number of vectors received from the server, to avoid
out of bound array access.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
contrib/ivshmem-client/ivshmem-client.c

index fcc0930..bfaf584 100644 (file)
@@ -128,6 +128,11 @@ ivshmem_client_handle_server_msg(IvshmemClient *client)
     /* new vector */
     IVSHMEM_CLIENT_DEBUG(client, "  new vector %d (fd=%d) for peer id %ld\n",
                          peer->vectors_count, fd, peer->id);
+    if (peer->vectors_count >= G_N_ELEMENTS(peer->vectors)) {
+        IVSHMEM_CLIENT_DEBUG(client, "Too many vectors received, failing");
+        return -1;
+    }
+
     peer->vectors[peer->vectors_count] = fd;
     peer->vectors_count++;