connection: return error on buffer-overflow during read
authorKristian Høgsberg <krh@bitplanet.net>
Mon, 15 Oct 2012 21:19:38 +0000 (17:19 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Mon, 15 Oct 2012 21:21:06 +0000 (17:21 -0400)
commit04720307e91c45a772858fd3fcb0203a0b68ac17
tree595d7ae1c90d6e1b9906a2e23563c9b9b4f10661
parentad03a59f5cab9e853dc024c801b49aa3ef6d33ff
connection: return error on buffer-overflow during read

wl_connection_read() assumes that the caller dispatched all messages
before calling it. wl_buffer_put_iov() does only provide enough room so we
fill the buffer. So the only case when the buffer overflows, is when a
previous read filled up the buffer but we couldn't parse a single message
from it. In this case, the client sent a message bigger than our buffer
and we should return an error and close the connection.

krh: Edited from Davids original patch to just check that the buffer
 isn't full before we try reading into it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/connection.c