GUACAMOLE-610: Limit terminal width/height to 1024 characters.
diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c
index ae34fdd..4447789 100644
--- a/src/terminal/terminal.c
+++ b/src/terminal/terminal.c
@@ -590,13 +590,29 @@
term->default_char = default_char;
term->clipboard = clipboard;
+ /* Calculate character size */
+ int rows = height / term->display->char_height;
+ int columns = available_width / term->display->char_width;
+
+ /* Keep height within predefined maximum */
+ if (rows > GUAC_TERMINAL_MAX_ROWS) {
+ rows = GUAC_TERMINAL_MAX_ROWS;
+ height = rows * term->display->char_height;
+ }
+
+ /* Keep width within predefined maximum */
+ if (columns > GUAC_TERMINAL_MAX_COLUMNS) {
+ columns = GUAC_TERMINAL_MAX_COLUMNS;
+ available_width = columns * term->display->char_width;
+ width = available_width + GUAC_TERMINAL_SCROLLBAR_WIDTH;
+ }
+
/* Set pixel size */
term->width = width;
term->height = height;
- /* Calculate character size */
- term->term_width = available_width / term->display->char_width;
- term->term_height = height / term->display->char_height;
+ term->term_width = columns;
+ term->term_height = rows;
/* Open STDIN pipe */
if (pipe(term->stdin_pipe_fd)) {
@@ -1508,6 +1524,19 @@
int rows = height / display->char_height;
int columns = available_width / display->char_width;
+ /* Keep height within predefined maximum */
+ if (rows > GUAC_TERMINAL_MAX_ROWS) {
+ rows = GUAC_TERMINAL_MAX_ROWS;
+ height = rows * display->char_height;
+ }
+
+ /* Keep width within predefined maximum */
+ if (columns > GUAC_TERMINAL_MAX_COLUMNS) {
+ columns = GUAC_TERMINAL_MAX_COLUMNS;
+ available_width = columns * display->char_width;
+ width = available_width + GUAC_TERMINAL_SCROLLBAR_WIDTH;
+ }
+
/* Set pixel sizes */
terminal->width = width;
terminal->height = height;
diff --git a/src/terminal/terminal/terminal.h b/src/terminal/terminal/terminal.h
index f153252..42a741a 100644
--- a/src/terminal/terminal/terminal.h
+++ b/src/terminal/terminal/terminal.h
@@ -38,6 +38,17 @@
#include <guacamole/stream.h>
/**
+ * The absolute maximum number of rows to allow within the display.
+ */
+#define GUAC_TERMINAL_MAX_ROWS 1024
+
+/**
+ * The absolute maximum number of columns to allow within the display. This
+ * implicitly limits the number of columns allowed within the buffer.
+ */
+#define GUAC_TERMINAL_MAX_COLUMNS 1024
+
+/**
* The maximum duration of a single frame, in milliseconds.
*/
#define GUAC_TERMINAL_FRAME_DURATION 40