File vte-emulation-resize-request-limits.patch of Package vte.34433

From fd5511f24b7269195a7083f409244e9787c705dc Mon Sep 17 00:00:00 2001
From: Christian Persch <chpe@src.gnome.org>
Date: Sun, 2 Jun 2024 19:13:15 +0200
Subject: [PATCH] emulation: Restrict resize request to sane numbers

Fixes: https://gitlab.gnome.org/GNOME/vte/-/issues/2786
---
 src/vteseq.cc | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff -urp vte-0.58.3.orig/src/vtedefines.hh vte-0.58.3/src/vtedefines.hh
--- vte-0.58.3.orig/src/vtedefines.hh	2019-11-22 15:36:35.000000000 -0600
+++ vte-0.58.3/src/vtedefines.hh	2024-06-12 03:11:40.559236308 -0500
@@ -139,3 +139,6 @@
 
 /* Maximum length of a paragraph, in lines, that might get proper RingView (BiDi) treatment. */
 #define VTE_RINGVIEW_PARAGRAPH_LENGTH_MAX   500
+
+#define VTE_MIN_GRID_WIDTH (2) /* space for one wide character */
+#define VTE_MIN_GRID_HEIGHT (1)
diff -urp vte-0.58.3.orig/src/vteseq.cc vte-0.58.3/src/vteseq.cc
--- vte-0.58.3.orig/src/vteseq.cc	2019-11-22 15:36:35.000000000 -0600
+++ vte-0.58.3/src/vteseq.cc	2024-06-12 03:10:09.474506874 -0500
@@ -243,9 +243,18 @@ Terminal::emit_move_window(guint x,
 /* Emit a "resize-window" signal.  (Grid size.) */
 void
 Terminal::emit_resize_window(guint columns,
-                                       guint rows)
+                             guint rows)
 {
-        _vte_debug_print(VTE_DEBUG_SIGNALS, "Emitting `resize-window'.\n");
+        // Ignore resizes with excessive number of rows or columns,
+        // see https://gitlab.gnome.org/GNOME/vte/-/issues/2786
+        if (columns < VTE_MIN_GRID_WIDTH ||
+            columns > 511 ||
+            rows < VTE_MIN_GRID_HEIGHT ||
+            rows > 511)
+                return;
+
+        _vte_debug_print(VTE_DEBUG_SIGNALS, "Emitting `resize-window' %d columns %d rows.\n",
+                         columns, rows);
         g_signal_emit(m_terminal, signals[SIGNAL_RESIZE_WINDOW], 0, columns, rows);
 }
 
@@ -4436,8 +4445,6 @@ Terminal::DECSLPP(vte::parser::Sequence
         else if (param < 24)
                 return;
 
-        _vte_debug_print(VTE_DEBUG_EMULATION, "Resizing to %d rows.\n", param);
-
         emit_resize_window(m_column_count, param);
 }
 
@@ -8667,9 +8674,6 @@ Terminal::XTERM_WM(vte::parser::Sequence
                 seq.collect(1, {&height, &width});
 
                 if (width != -1 && height != -1) {
-                        _vte_debug_print(VTE_DEBUG_EMULATION,
-                                         "Resizing window to %d columns, %d rows.\n",
-                                         width, height);
                         emit_resize_window(width, height);
                 }
                 break;
openSUSE Build Service is sponsored by