]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.c
Limit the size of the fd read buffer in channel_poll().
[meshlink] / src / meshlink.c
index 14ff7155888c96a04ff33945dfd71dcf9e4481dd..e50be188b32ef9b19b96c2961766da4ef2d60bc4 100644 (file)
@@ -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);