Fix crash when the command line is shorter than 1024 characters

https://bugzilla.redhat.com/show_bug.cgi?id=1833759
This commit is contained in:
Ting-Wei Lan 2020-11-20 23:44:09 +01:00 committed by Debarshi Ray
parent 46de13c564
commit 347377a4ef
2 changed files with 46 additions and 35 deletions

View File

@ -231,7 +231,7 @@ index 7a8953c50388..a3d77bf6719d 100644
uuid_unparse (u, uuidstr);
priv->uuid = g_strdup (uuidstr);
--
2.25.4
2.28.0
From c75db4814eaee946daccc526c5f37124f1981352 Mon Sep 17 00:00:00 2001
@ -293,7 +293,7 @@ index a3d77bf6719d..36d155a9e420 100644
widget_class->screen_changed = terminal_window_screen_changed;
widget_class->style_updated = terminal_window_style_updated;
--
2.25.4
2.28.0
From e7810e47cf096ce6901e572bb9f5256601aed62d Mon Sep 17 00:00:00 2001
@ -428,7 +428,7 @@ index 36d155a9e420..c0219d872725 100644
return GTK_WIDGET_CLASS (terminal_window_parent_class)->draw (widget, cr);
--
2.25.4
2.28.0
From de1231cf68fbe55ab7b7b2c4660091bfb05ec493 Mon Sep 17 00:00:00 2001
@ -498,7 +498,7 @@ index a1c3161391da..e2545c3f9288 100644
#endif
--
2.25.4
2.28.0
From b4a8b69b27a26f95371a1780ad61e97529cb8f90 Mon Sep 17 00:00:00 2001
@ -751,7 +751,7 @@ index e2545c3f9288..57ea1cce26d5 100644
return FALSE;
--
2.25.4
2.28.0
From 3e7242e41500b5a7c85133dc15a0b290cd67d861 Mon Sep 17 00:00:00 2001
@ -1071,7 +1071,7 @@ index 20cfbceb36b0..a987025e0524 100644
G_END_DECLS
--
2.25.4
2.28.0
From a6dbcf9b15ae96829c5a1c20e2901c722457b3c6 Mon Sep 17 00:00:00 2001
@ -1346,7 +1346,7 @@ index 64f8295bf2b0..426993a4e154 100644
</object>
<packing>
--
2.25.4
2.28.0
From 528ffc16192fbd45fdb709a0c58dd5f51ab524e9 Mon Sep 17 00:00:00 2001
@ -1639,7 +1639,7 @@ index 426993a4e154..7f4a94c88b6b 100644
</object>
<packing>
--
2.25.4
2.28.0
From c95d6adef9b1c1c447249a44eb56750b321000e0 Mon Sep 17 00:00:00 2001
@ -1818,7 +1818,7 @@ index 8ea337867222..049bbe5a2b8b 100644
char *terminal_screen_get_current_dir (TerminalScreen *screen);
--
2.25.4
2.28.0
From 9c755aefcb53d63da73214a911ab75dd4fe6b7e2 Mon Sep 17 00:00:00 2001
@ -1997,7 +1997,7 @@ index 91c76df3feea..7724af0dfa04 100644
(!prop_name ||
prop_name == I_(TERMINAL_PROFILE_USE_SYSTEM_FONT_KEY) ||
--
2.25.4
2.28.0
From f0e0ecdab4c22e7e1f44b5da9a6618c6563c5f5b Mon Sep 17 00:00:00 2001
@ -4741,7 +4741,7 @@ index 80cb23434a60..20e2a93ce3f0 100644
+msgid "Transparent background"
+msgstr "透明背景"
--
2.25.4
2.28.0
From fc5845548ab6cbf56888c81fafdf63659ef9c337 Mon Sep 17 00:00:00 2001
@ -4889,7 +4889,7 @@ index c0219d872725..61c5e7de350a 100644
{ "tab-detach", action_tab_detach_cb, NULL, NULL, NULL },
{ "tab-move-left", action_tab_move_left_cb, NULL, NULL, NULL },
--
2.25.4
2.28.0
From e5d3a23ff1f72a2fb2887abcbcb9a4d33dd4cdc3 Mon Sep 17 00:00:00 2001
@ -4919,7 +4919,7 @@ index 7724af0dfa04..3e93ab8ff7e5 100644
const char *p;
--
2.25.4
2.28.0
From 4dbaed23edd26456c0509d4bc5424acbdb9140f9 Mon Sep 17 00:00:00 2001
@ -5536,22 +5536,24 @@ index 61c5e7de350a..0d61db3c125d 100644
static void
--
2.25.4
2.28.0
From a8afd6f8f6214a26f777c0412ce0d7cc3ebdea81 Mon Sep 17 00:00:00 2001
From 19071280279ea0a81ecda37e5b24fd1d372c34c0 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Wed, 3 Apr 2019 15:38:09 +0200
Subject: [PATCH 15/16] Update the title with the current foreground process
Some changes by Bill Nottingham <notting@splat.cc>
Some changes by:
Bill Nottingham <notting@splat.cc>
Ting-Wei Lan <lantw44@gmail.com>
https://bugzilla.gnome.org/show_bug.cgi?id=711060
---
src/org.gnome.Terminal.gschema.xml | 5 ++++
src/terminal-schemas.h | 1 +
src/terminal-screen.c | 39 +++++++++++++++++++++++++++++-
3 files changed, 44 insertions(+), 1 deletion(-)
src/terminal-screen.c | 45 +++++++++++++++++++++++++++++-
3 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/src/org.gnome.Terminal.gschema.xml b/src/org.gnome.Terminal.gschema.xml
index 53083a0e15d3..d7e12d831796 100644
@ -5582,7 +5584,7 @@ index 78e7a9a54b60..88dd11254c0d 100644
#define TERMINAL_PROFILE_TITLE_MODE_KEY "title-mode"
#define TERMINAL_PROFILE_TITLE_KEY "title"
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index 95ad21f6e867..399dc889b96a 100644
index 95ad21f6e867..71c98503caf9 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -109,7 +109,9 @@ struct _TerminalScreenPrivate
@ -5595,7 +5597,7 @@ index 95ad21f6e867..399dc889b96a 100644
gboolean user_title; /* title was manually set */
char *current_cmdline;
char *raw_title;
@@ -1160,6 +1162,20 @@ terminal_screen_format_title (TerminalScreen *screen,
@@ -1160,6 +1162,26 @@ terminal_screen_format_title (TerminalScreen *screen,
add_sep = FALSE;
}
@ -5607,16 +5609,22 @@ index 95ad21f6e867..399dc889b96a 100644
+ {
+ gs_free char *current_cmdline_truncated = NULL;
+ gs_free char *current_cmdline_valid = NULL;
+ glong len_truncated;
+ glong len_valid;
+
+ current_cmdline_valid = g_utf8_make_valid (priv->current_cmdline, -1);
+ current_cmdline_truncated = g_utf8_substring (current_cmdline_valid, 0, 1024);
+ len_valid = g_utf8_strlen (current_cmdline_valid, -1);
+
+ len_truncated = len_valid > 1024 ? 1024 : len_valid;
+ current_cmdline_truncated = g_utf8_substring (current_cmdline_valid, 0, len_truncated);
+
+ g_string_append_printf (title, " — %s", current_cmdline_truncated);
+ }
+
if (*titleptr == NULL || strcmp (title->str, *titleptr) != 0)
{
g_free (*titleptr);
@@ -1189,6 +1205,7 @@ terminal_screen_profile_changed_cb (GSettings *profile,
@@ -1189,6 +1211,7 @@ terminal_screen_profile_changed_cb (GSettings *profile,
GObject *object = G_OBJECT (screen);
VteTerminal *vte_terminal = VTE_TERMINAL (screen);
TerminalWindow *window;
@ -5624,7 +5632,7 @@ index 95ad21f6e867..399dc889b96a 100644
g_object_freeze_notify (object);
@@ -1223,7 +1240,7 @@ terminal_screen_profile_changed_cb (GSettings *profile,
@@ -1223,7 +1246,7 @@ terminal_screen_profile_changed_cb (GSettings *profile,
prop_name == I_(TERMINAL_PROFILE_TITLE_MODE_KEY) ||
prop_name == I_(TERMINAL_PROFILE_TITLE_KEY))
{
@ -5633,7 +5641,7 @@ index 95ad21f6e867..399dc889b96a 100644
}
if (gtk_widget_get_realized (GTK_WIDGET (screen)) &&
@@ -1251,6 +1268,13 @@ terminal_screen_profile_changed_cb (GSettings *profile,
@@ -1251,6 +1274,13 @@ terminal_screen_profile_changed_cb (GSettings *profile,
prop_name == I_(TERMINAL_PROFILE_BACKGROUND_TRANSPARENCY_PERCENT))
update_color_scheme (screen);
@ -5647,7 +5655,7 @@ index 95ad21f6e867..399dc889b96a 100644
if (!prop_name || prop_name == I_(TERMINAL_PROFILE_AUDIBLE_BELL_KEY))
vte_terminal_set_audible_bell (vte_terminal, g_settings_get_boolean (profile, TERMINAL_PROFILE_AUDIBLE_BELL_KEY));
@@ -1315,6 +1339,9 @@ terminal_screen_profile_changed_cb (GSettings *profile,
@@ -1315,6 +1345,9 @@ terminal_screen_profile_changed_cb (GSettings *profile,
vte_terminal_set_word_char_exceptions (vte_terminal, word_char_exceptions);
}
@ -5657,7 +5665,7 @@ index 95ad21f6e867..399dc889b96a 100644
g_object_thaw_notify (object);
}
@@ -2141,6 +2168,9 @@ static void
@@ -2141,6 +2174,9 @@ static void
terminal_screen_window_title_changed (VteTerminal *vte_terminal,
TerminalScreen *screen)
{
@ -5667,7 +5675,7 @@ index 95ad21f6e867..399dc889b96a 100644
terminal_screen_set_dynamic_title (screen,
vte_terminal_get_window_title (vte_terminal),
FALSE);
@@ -2247,6 +2277,8 @@ terminal_screen_contents_changed_cb (TerminalScreen *screen)
@@ -2247,6 +2283,8 @@ terminal_screen_contents_changed_cb (TerminalScreen *screen)
priv->current_cmdline = g_steal_pointer (&cmdline);
_terminal_debug_print (TERMINAL_DEBUG_SHELL_COMMAND, "Current foreground command-line: %s\n", priv->current_cmdline);
@ -5676,7 +5684,7 @@ index 95ad21f6e867..399dc889b96a 100644
out:
priv->contents_changed_source_id = 0;
return G_SOURCE_REMOVE;
@@ -2339,6 +2371,7 @@ terminal_screen_shell_precmd (VteTerminal *terminal)
@@ -2339,6 +2377,7 @@ terminal_screen_shell_precmd (VteTerminal *terminal)
_terminal_debug_print (TERMINAL_DEBUG_SHELL_COMMAND, "Shell precmd\n");
@ -5684,7 +5692,7 @@ index 95ad21f6e867..399dc889b96a 100644
priv->between_preexec_and_precmd = FALSE;
if (priv->contents_changed_source_id != 0)
@@ -2358,6 +2391,8 @@ terminal_screen_shell_precmd (VteTerminal *terminal)
@@ -2358,6 +2397,8 @@ terminal_screen_shell_precmd (VteTerminal *terminal)
g_clear_pointer (&priv->current_cmdline, g_free);
_terminal_debug_print (TERMINAL_DEBUG_SHELL_COMMAND, "Current foreground command-line: (none)\n");
@ -5693,7 +5701,7 @@ index 95ad21f6e867..399dc889b96a 100644
}
static gboolean
@@ -2378,6 +2413,8 @@ terminal_screen_shell_preexec_cb (TerminalScreen *screen)
@@ -2378,6 +2419,8 @@ terminal_screen_shell_preexec_cb (TerminalScreen *screen)
priv->current_cmdline = g_steal_pointer (&cmdline);
_terminal_debug_print (TERMINAL_DEBUG_SHELL_COMMAND, "Current foreground command-line: %s\n", priv->current_cmdline);
@ -5703,10 +5711,10 @@ index 95ad21f6e867..399dc889b96a 100644
retval = G_SOURCE_REMOVE;
--
2.25.4
2.28.0
From 6fcc54a2475fa4d248f6b78ead8625e2d3e1ae9d Mon Sep 17 00:00:00 2001
From 8cfe298ce5bc7123d58a14a1746d6b51ce7b26c2 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Thu, 27 Feb 2020 19:32:08 +0100
Subject: [PATCH 16/16] screen, window: Preserve current toolbox, if any
@ -5722,7 +5730,7 @@ https://gitlab.freedesktop.org/terminal-wg/specifications/issues/17
3 files changed, 59 insertions(+), 3 deletions(-)
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index 399dc889b96a..db088f6f2695 100644
index 71c98503caf9..80e86b55ba40 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -877,6 +877,25 @@ terminal_screen_reexec_from_screen (TerminalScreen *screen,
@ -5825,5 +5833,5 @@ index 0d61db3c125d..ad3a95af7008 100644
if (mode == TERMINAL_NEW_TERMINAL_MODE_WINDOW)
gtk_window_present (GTK_WINDOW (window));
--
2.25.4
2.28.0

View File

@ -8,7 +8,7 @@
Name: gnome-terminal
Version: 3.38.1
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Terminal emulator for GNOME
License: GPLv3+ and GFDL and LGPLv2+
@ -113,6 +113,9 @@ make check
%{_datadir}/metainfo/org.gnome.Terminal.Nautilus.metainfo.xml
%changelog
* Fri Nov 20 2020 Ting-Wei Lan <lantw44@gmail.com> - 3.38.1-2
- Fix crash when the command line is shorter than 1024 characters
* Mon Oct 12 2020 Debarshi Ray <rishi@fedoraproject.org> - 3.38.1-1
- Update to 3.38.1
- Backport yet-to-be-released patches from upstream