summaryrefslogtreecommitdiff
path: root/server/main_channel.c
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2016-11-29 16:46:56 +0000
committerFrediano Ziglio <fziglio@redhat.com>2017-02-06 10:35:54 +0000
commit5f96b596353d73bdf4bb3cd2de61e48a7fd5b4c3 (patch)
tree74bf789bd021eb811f2675fb67e954b720694761 /server/main_channel.c
parentf66dc643635518e53dfbe5262f814a64eec54e4a (diff)
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>
Diffstat (limited to 'server/main_channel.c')
-rw-r--r--server/main_channel.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/server/main_channel.c b/server/main_channel.c
index 0ecc9df8..1fc39155 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -1026,6 +1026,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(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;
}