Commit 95204aa9 authored by Marc-André Lureau's avatar Marc-André Lureau
Browse files

ivshmem-client: check the number of vectors



Check the number of vectors received from the server, to avoid
out of bound array access.

Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: default avatarClaudio Fontana <claudio.fontana@huawei.com>
parent a75eb03b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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++;