Skip to content

Commit

Permalink
ivshmem-client: check the number of vectors
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
elmarco committed Oct 24, 2015
1 parent a75eb03 commit 95204aa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions contrib/ivshmem-client/ivshmem-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;

Expand Down

0 comments on commit 95204aa

Please sign in to comment.