[vte] ring: Don't reset the stream offsets to 0 on ring reset



commit 2e1d9354a6cd16908b44793e0be321bd97f9081b
Author: Egmont Koblinger <egmont gmail com>
Date:   Sun Jan 18 17:11:48 2015 +0100

    ring: Don't reset the stream offsets to 0 on ring reset
    
    This is required for encryption, so that we don't reuse the same IV.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738601#c93

 src/ring.c |   14 ++++++++------
 src/ring.h |    2 +-
 src/vte.c  |   18 ++++++------------
 3 files changed, 15 insertions(+), 19 deletions(-)
---
diff --git a/src/ring.c b/src/ring.c
index 3d04453..bd9191b 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -321,22 +321,24 @@ _vte_ring_reset_streams (VteRing *ring, gulong position)
 
        if (ring->has_streams) {
                _vte_stream_reset (ring->row_stream, position * sizeof (VteRowRecord));
-               _vte_stream_reset (ring->text_stream, 0);
-               _vte_stream_reset (ring->attr_stream, 0);
+                _vte_stream_reset (ring->text_stream, _vte_stream_head (ring->text_stream));
+                _vte_stream_reset (ring->attr_stream, _vte_stream_head (ring->attr_stream));
        }
 
        ring->last_attr_text_start_offset = 0;
        ring->last_attr.i = basic_cell.i.attr;
 }
 
-void
+long
 _vte_ring_reset (VteRing *ring)
 {
-        _vte_debug_print (VTE_DEBUG_RING, "Reseting the ring.\n");
+        _vte_debug_print (VTE_DEBUG_RING, "Reseting the ring at %lu.\n", ring->end);
 
-        _vte_ring_reset_streams (ring, 0);
-        ring->start = ring->end = ring->writable = 0;
+        _vte_ring_reset_streams (ring, ring->end);
+        ring->start = ring->writable = ring->end;
         ring->cached_row_num = (gulong) -1;
+
+        return ring->end;
 }
 
 static inline VteRowData *
diff --git a/src/ring.h b/src/ring.h
index 58b8731..e3dc4b3 100644
--- a/src/ring.h
+++ b/src/ring.h
@@ -81,7 +81,7 @@ VteRowData *_vte_ring_index_writable (VteRing *ring, gulong position);
 
 void _vte_ring_init (VteRing *ring, gulong max_rows, gboolean has_streams);
 void _vte_ring_fini (VteRing *ring);
-void _vte_ring_reset (VteRing *ring);
+long _vte_ring_reset (VteRing *ring);
 void _vte_ring_resize (VteRing *ring, gulong max_rows);
 void _vte_ring_shrink (VteRing *ring, gulong max_len);
 VteRowData *_vte_ring_insert (VteRing *ring, gulong position);
diff --git a/src/vte.c b/src/vte.c
index 6ec37c3..3da2807 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -11848,23 +11848,17 @@ vte_terminal_reset(VteTerminal *terminal,
        /* Clear the scrollback buffers and reset the cursors. Switch to normal screen. */
        if (clear_history) {
                 pvt->screen = &pvt->normal_screen;
-                _vte_ring_reset(pvt->normal_screen.row_data);
-                _vte_ring_reset(pvt->alternate_screen.row_data);
-                pvt->normal_screen.saved.cursor.row = 0;
-                pvt->normal_screen.saved.cursor.col = 0;
-               pvt->normal_screen.scroll_delta = 0;
-               pvt->normal_screen.insert_delta = 0;
-                pvt->alternate_screen.saved.cursor.row = 0;
-                pvt->alternate_screen.saved.cursor.col = 0;
-               pvt->alternate_screen.scroll_delta = 0;
-               pvt->alternate_screen.insert_delta = 0;
-                pvt->cursor.row = 0;
+                pvt->normal_screen.scroll_delta = pvt->normal_screen.insert_delta =
+                        _vte_ring_reset(pvt->normal_screen.row_data);
+                pvt->alternate_screen.scroll_delta = pvt->alternate_screen.insert_delta =
+                        _vte_ring_reset(pvt->alternate_screen.row_data);
+                pvt->cursor.row = pvt->screen->insert_delta;
                 pvt->cursor.col = 0;
                 /* Adjust the scrollbar to the new location. */
                 /* Hack: force a change in scroll_delta even if the value remains, so that
                    vte_term_q_adj_val_changed() doesn't shortcut to no-op, see bug 730599. */
                 pvt->screen->scroll_delta = -1;
-                vte_terminal_queue_adjustment_value_changed (terminal, 0);
+                vte_terminal_queue_adjustment_value_changed (terminal, pvt->screen->insert_delta);
                _vte_terminal_adjust_adjustments_full (terminal);
        }
         /* DECSCUSR cursor style */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]