File vte-emulation-resize-request-limits.patch of Package vte.34434
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.44.2.orig/src/vtedefines.hh vte-0.44.2/src/vtedefines.hh
--- vte-0.44.2.orig/src/vtedefines.hh 2016-05-10 10:17:33.000000000 -0500
+++ vte-0.44.2/src/vtedefines.hh 2024-06-12 03:27:13.273424524 -0500
@@ -93,3 +93,6 @@
#define VTE_FONT_SCALE_MIN (.25)
#define VTE_FONT_SCALE_MAX (4.)
+
+#define VTE_MIN_GRID_WIDTH (2) /* space for one wide character */
+#define VTE_MIN_GRID_HEIGHT (1)
diff -urp vte-0.44.2.orig/src/vteseq.cc vte-0.44.2/src/vteseq.cc
--- vte-0.44.2.orig/src/vteseq.cc 2016-05-10 10:17:33.000000000 -0500
+++ vte-0.44.2/src/vteseq.cc 2024-06-12 03:30:30.083031124 -0500
@@ -198,7 +198,16 @@ void
VteTerminalPrivate::emit_resize_window(guint columns,
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);
}
@@ -3098,10 +3107,6 @@ VteTerminalPrivate::seq_window_manipulat
break;
case 8:
if ((arg1 != -1) && (arg2 != -1)) {
- _vte_debug_print(VTE_DEBUG_PARSE,
- "Resizing window "
- "(to %ld columns, %ld rows).\n",
- arg2, arg1);
emit_resize_window(arg2, arg1);
}
break;
@@ -3210,9 +3215,6 @@ VteTerminalPrivate::seq_window_manipulat
break;
default:
if (param >= 24) {
- _vte_debug_print(VTE_DEBUG_PARSE,
- "Resizing to %ld rows.\n",
- param);
/* Resize to the specified number of
* rows. */
emit_resize_window(m_column_count,