From f95981a276aa0dbd03f51190949fa8c5db74d8ff Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Thu, 21 May 2020 00:13:50 +0200 Subject: [PATCH] Limit the size of the fd read buffer in channel_poll(). --- src/meshlink.c | 5 +++++ 1 file changed, 5 insertions(+) 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); -- 2.39.5