GUACAMOLE-610: Limit terminal width/height to 1024 characters.

This commit is contained in:
Michael Jumper 2018-08-12 22:37:24 -07:00
parent 0062f61d67
commit 6a576f0121
2 changed files with 43 additions and 3 deletions

View File

@ -590,13 +590,29 @@ guac_terminal* guac_terminal_create(guac_client* client,
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 guac_terminal_resize(guac_terminal* terminal, int width, int height) {
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;

View File

@ -37,6 +37,17 @@
#include <guacamole/client.h>
#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.
*/