main-channel: Prevent overflow reading messages from client

Caller is supposed the function return a buffer able to store
size bytes.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Frediano Ziglio 2016-11-29 16:46:56 +00:00
parent e16eee1d8b
commit 1d3e26c0ee

View File

@ -258,6 +258,9 @@ static uint8_t *main_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
if (type == SPICE_MSGC_MAIN_AGENT_DATA) {
return reds_get_agent_data_buffer(red_channel_get_server(channel), mcc, size);
} else if (size > sizeof(main_chan->recv_buf)) {
/* message too large, caller will log a message and close the connection */
return NULL;
} else {
return main_chan->recv_buf;
}