mirror of
https://github.com/qemu/qemu.git
synced 2024-11-24 19:33:39 +08:00
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: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
This commit is contained in:
parent
a75eb03b9f
commit
95204aa951
@ -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++;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user