From 1178b475dad6b8c567041dda8e3fabd34a584f75 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 1 Sep 2018 21:41:13 -0700 Subject: [PATCH] GUACAMOLE-622: Do not allow STDIN to be redirected if the terminal is not yet started. --- src/terminal/terminal-stdin-stream.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/terminal/terminal-stdin-stream.c b/src/terminal/terminal-stdin-stream.c index 1f662d67..02f5b943 100644 --- a/src/terminal/terminal-stdin-stream.c +++ b/src/terminal/terminal-stdin-stream.c @@ -103,6 +103,22 @@ static int guac_terminal_input_stream_end_handler(guac_user* user, static int __guac_terminal_send_stream(guac_terminal* term, guac_user* user, guac_stream* stream) { + /* Deny redirecting STDIN if terminal is not started */ + if (!term->started) { + + guac_user_log(user, GUAC_LOG_DEBUG, "Attempt to direct the contents " + "of an inbound stream to STDIN denied. The terminal is not " + "yet ready for input."); + + guac_protocol_send_ack(user->socket, stream, + "Terminal not yet started.", + GUAC_PROTOCOL_STATUS_RESOURCE_CONFLICT); + + guac_socket_flush(user->socket); + return 1; + + } + /* If a stream is already being used for STDIN, deny creation of * further streams */ if (term->input_stream != NULL) {