From: Girts Date: Sat, 6 Jun 2020 13:51:15 +0000 (-0700) Subject: protocol: fix readonly handling (#373) X-Git-Url: http://git.prime8.dev/?a=commitdiff_plain;h=56d26accd325265e4f9350ea080096f5fc9e01c6;p=ttyd.git protocol: fix readonly handling (#373) Previously, if running in readonly mode (`-R`), we would keep accumulating incoming websocket data to `pss->buffer`, resizing it with every incoming message. This would also break the `RESIZE` operation as we would never get rid of the `INPUT` message. Now we discard `INPUT` messages in `readonly` mode, 1) allowing resize to work and 2) preventing the buffer from growing indefinitely. --- diff --git a/src/protocol.c b/src/protocol.c index 9586075..fbefa54 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -358,7 +358,7 @@ int callback_tty(struct lws *wsi, enum lws_callback_reasons reason, void *user, switch (command) { case INPUT: if (proc->pty == 0) break; - if (server->readonly) return 0; + if (server->readonly) break; char *data = xmalloc(pss->len - 1); memcpy(data, pss->buffer + 1, pss->len - 1);