From c03d5be7375f3ea3175ff712f51c48c3e358b12d Mon Sep 17 00:00:00 2001 From: fortunate-lee Date: Tue, 15 Apr 2025 17:25:59 +0800 Subject: [PATCH] fix Implicit previous shell_line execution --- ...mplicit-previous-shell_line-excution.patch | 44 +++++++++++++++++++ util-linux.spec | 9 +++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 backport-fix-implicit-previous-shell_line-excution.patch diff --git a/backport-fix-implicit-previous-shell_line-excution.patch b/backport-fix-implicit-previous-shell_line-excution.patch new file mode 100644 index 0000000..757da2a --- /dev/null +++ b/backport-fix-implicit-previous-shell_line-excution.patch @@ -0,0 +1,44 @@ +diff -Naur util-linux-2.37.2-bak/text-utils/more.c util-linux-2.37.2/text-utils/more.c +--- util-linux-2.37.2-bak/text-utils/more.c 2025-04-15 17:10:51.945311345 +0800 ++++ util-linux-2.37.2/text-utils/more.c 2025-04-15 17:17:14.867110743 +0800 +@@ -221,6 +221,7 @@ + print_banner:1, /* print file name banner */ + reading_num:1, /* are we reading leading_number */ + report_errors:1, /* is an error reported */ ++ prev_command_called:1, /* previous more command is called */ + search_at_start:1, /* search pattern defined at start up */ + search_called:1, /* previous more command was a search */ + squeeze_spaces:1, /* suppress white space */ +@@ -1285,8 +1286,11 @@ + erase_to_col(ctl, 0); + putchar('!'); + fflush(NULL); +- if (ctl->previous_command.key == more_kc_run_shell && ctl->shell_line) ++ if (ctl->previous_command.key == more_kc_run_shell && ctl->shell_line ++ && ctl->prev_command_called == 1) { + fputs(ctl->shell_line, stdout); ++ ctl->prev_command_called = 0; ++ } + else { + ttyin(ctl, cmdbuf, sizeof(cmdbuf) - 2, '!'); + if (strpbrk(cmdbuf, "%!\\")) +@@ -1664,6 +1668,7 @@ + else + ctl->report_errors = 0; + ctl->search_called = 0; ++ ctl->prev_command_called = 0; + for (;;) { + if (more_poll(ctl, -1, &stderr_active) <= 0) + continue; +@@ -1672,8 +1677,10 @@ + cmd = read_command(ctl); + if (cmd.key == more_kc_unknown_command) + continue; +- if (cmd.key == more_kc_repeat_previous) ++ if (cmd.key == more_kc_repeat_previous) { + cmd = ctl->previous_command; ++ ctl->prev_command_called = 1; ++ } + switch (cmd.key) { + case more_kc_backwards: + if (ctl->no_tty_in) { diff --git a/util-linux.spec b/util-linux.spec index 504f297..05153f0 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -3,7 +3,7 @@ Name: util-linux Version: 2.37.2 -Release: 43 +Release: 44 Summary: A random collection of Linux utilities License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain URL: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git @@ -177,6 +177,7 @@ Patch9003: backport-uuidd-fix-open-lock-state-issue.patch Patch9004: sfdisk-fix-crash-casued-by-out-of-bounds-access.patch Patch9005: Add-new-cpu-model-name-of-arm-Kunpeng.patch Patch9006: mkfs.bfs-fix-memory-leaks-and-weak-code.patch +Patch9007: backport-fix-implicit-previous-shell_line-excution.patch BuildRequires: audit-libs-devel >= 1.0.6 gettext-devel libselinux-devel ncurses-devel pam-devel zlib-devel popt-devel BuildRequires: libutempter-devel systemd-devel systemd libuser-devel libcap-ng-devel python3-devel gcc autoconf automake @@ -547,6 +548,12 @@ fi %{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*} %changelog +* Tue Apr 15 2025 lijian - 2.37.2-44 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:Implicit previous shell_line execution + * Tue Apr 15 2025 zhangyao - 2.37.2-43 - Type:bugfix - CVE:NA -- Gitee