Repository: guacamole-server
Updated Branches:
  refs/heads/master f5b5ac718 -> 79ce5ad8b


GUACAMOLE-573: Ensure scrollback buffer bounds cannot be exceeded. Remove 
incorrect bounds checks.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/b0b0b186
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/b0b0b186
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/b0b0b186

Branch: refs/heads/master
Commit: b0b0b186f5f9e57bfe93ed96c8c3a1e9fc4f192b
Parents: f5b5ac7
Author: Michael Jumper <[email protected]>
Authored: Tue Jul 17 21:55:46 2018 -0700
Committer: Michael Jumper <[email protected]>
Committed: Tue Jul 17 21:55:46 2018 -0700

----------------------------------------------------------------------
 src/terminal/buffer.c          |  6 ++----
 src/terminal/select.c          | 12 ------------
 src/terminal/terminal/buffer.h |  5 ++++-
 3 files changed, 6 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/b0b0b186/src/terminal/buffer.c
----------------------------------------------------------------------
diff --git a/src/terminal/buffer.c b/src/terminal/buffer.c
index 2985592..4ecc5ba 100644
--- a/src/terminal/buffer.c
+++ b/src/terminal/buffer.c
@@ -83,12 +83,10 @@ guac_terminal_buffer_row* 
guac_terminal_buffer_get_row(guac_terminal_buffer* buf
     guac_terminal_char* first;
     guac_terminal_buffer_row* buffer_row;
 
-    /* Calculate scrollback row index */
-    int index = buffer->top + row;
+    /* Normalize row index into a scrollback buffer index */
+    int index = (buffer->top + row) % buffer->available;
     if (index < 0)
         index += buffer->available;
-    else if (index >= buffer->available)
-        index -= buffer->available;
 
     /* Get row */
     buffer_row = &(buffer->rows[index]);

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/b0b0b186/src/terminal/select.c
----------------------------------------------------------------------
diff --git a/src/terminal/select.c b/src/terminal/select.c
index 131b5f6..20fc3cd 100644
--- a/src/terminal/select.c
+++ b/src/terminal/select.c
@@ -149,12 +149,6 @@ static int guac_terminal_find_char(guac_terminal* terminal,
 
     int start_column = *column;
 
-    /* If requested row is outside the bounds of the current terminal or
-     * scrollback, assume the character is 1 column wide */
-    if (row >= terminal->term_height
-            || row < terminal->term_height - terminal->buffer->length)
-        return 1;
-
     guac_terminal_buffer_row* buffer_row = 
guac_terminal_buffer_get_row(terminal->buffer, row, 0);
     if (start_column < buffer_row->length) {
 
@@ -291,12 +285,6 @@ static void 
guac_terminal_clipboard_append_row(guac_terminal* terminal,
     char buffer[1024];
     int i = start;
 
-    /* If requested row is outside the bounds of the current terminal or
-     * scrollback, do nothing */
-    if (row >= terminal->term_height
-            || row < terminal->term_height - terminal->buffer->length)
-        return;
-
     guac_terminal_buffer_row* buffer_row =
         guac_terminal_buffer_get_row(terminal->buffer, row, 0);
 

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/b0b0b186/src/terminal/terminal/buffer.h
----------------------------------------------------------------------
diff --git a/src/terminal/terminal/buffer.h b/src/terminal/terminal/buffer.h
index db2a4a1..0e08226 100644
--- a/src/terminal/terminal/buffer.h
+++ b/src/terminal/terminal/buffer.h
@@ -70,7 +70,10 @@ typedef struct guac_terminal_buffer {
     guac_terminal_buffer_row* rows;
 
     /**
-     * The row to replace when adding a new row to the buffer.
+     * The index of the first row in the buffer (the row which represents row 0
+     * with respect to the terminal display). This is also the index of the row
+     * to replace when insufficient space remains in the buffer to add a new
+     * row.
      */
     int top;
 

Reply via email to