From: Guus Sliepen Date: Wed, 20 May 2020 22:13:50 +0000 (+0200) Subject: Limit the size of the fd read buffer in channel_poll(). X-Git-Url: http://git.meshlink.io/?p=meshlink;a=commitdiff_plain;h=f95981a276aa0dbd03f51190949fa8c5db74d8ff;hp=184155443a03b095155b210945a705b7f936cc4d Limit the size of the fd read buffer in channel_poll(). --- diff --git a/src/meshlink.c b/src/meshlink.c index 14ff7155..e50be188 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -3675,6 +3675,11 @@ static void channel_poll(struct utcp_connection *connection, size_t len) { if(aio->data) { sent = utcp_send(connection, (char *)aio->data + aio->done, todo); } else { + /* Limit the amount we read at once to avoid stack overflows */ + if(todo > 65536) { + todo = 65536; + } + char buf[todo]; ssize_t result = read(aio->fd, buf, todo);