From 770d63366a6eb82258a928d8358794b19334e996 Mon Sep 17 00:00:00 2001 From: EulerOSWander <314264452@qq.com> Date: Wed, 30 Jun 2021 17:37:00 +0800 Subject: [PATCH] sync upstream patches sync upstream patches Signed-off-by: EulerOSWander <314264452@qq.com> --- ...ential-alternate-display-mode-abends.patch | 79 +++++++++++++++++++ ...ye-function-replace-fputs-with-the-w.patch | 35 ++++++++ procps-ng.spec | 7 +- 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 backport-0014-top-fix-two-potential-alternate-display-mode-abends.patch create mode 100644 backport-0015-top-In-the-bye_bye-function-replace-fputs-with-the-w.patch diff --git a/backport-0014-top-fix-two-potential-alternate-display-mode-abends.patch b/backport-0014-top-fix-two-potential-alternate-display-mode-abends.patch new file mode 100644 index 0000000..1606408 --- /dev/null +++ b/backport-0014-top-fix-two-potential-alternate-display-mode-abends.patch @@ -0,0 +1,79 @@ +From 84e85611c36d31a478e1b62e5668671d9389265d Mon Sep 17 00:00:00 2001 +From: Jim Warner +Date: Mon, 31 May 2021 00:00:00 -0500 +Subject: [PATCH] top: fix two potential 'alternate display mode' abends + +This commit will address potential abends upon leaving +the windows help or color mapping screens and invoking +alternate display mode ('A'). It only happens if that +current window was changed with multiple 'a'/'w' keys. + +So now, rather than leaving a trail of negative values +in the 'begtask' field, compliments of that win_select +function, we'll remove the mkVIZrow1 macro. Henceforth +it will be issued just once per user interaction. Thus +a promise of 'Curwin' only being impacted is restored. + +[ my thanks to Vladimir Chren for reporting this bug ] + +Reference(s): +https://gitlab.com/procps-ng/procps/-/issues/210 +https://gitlab.com/procps-ng/procps/-/merge_requests/135 + +Discovered by:Vladimir Chren +Signed-off-by: Jim Warner +--- + top/top.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/top/top.c b/top/top.c +index c1f30fb..dd6e3d5 100644 +--- a/top/top.c ++++ b/top/top.c +@@ -4475,7 +4475,6 @@ static WIN_t *win_select (int ch) { + break; + } + Curwin = w; +- mkVIZrow1(Curwin); + return Curwin; + } // end: win_select + +@@ -5148,6 +5147,7 @@ static void keys_global (int ch) { + case '?': + case 'h': + help_view(); ++ mkVIZrow1(Curwin); + break; + case 'B': + TOGw(w, View_NOBOLD); +@@ -5175,6 +5175,7 @@ static void keys_global (int ch) { + break; + case 'g': + win_select(0); ++ mkVIZrow1(Curwin); + break; + case 'H': + Thread_mode = !Thread_mode; +@@ -5254,6 +5255,7 @@ static void keys_global (int ch) { + break; + case 'Z': + wins_colors(); ++ mkVIZrow1(Curwin); + break; + case '0': + Rc.zero_suppress = !Rc.zero_suppress; +@@ -5573,7 +5575,10 @@ static void keys_window (int ch) { + break; + case 'a': + case 'w': +- if (ALTCHKw) win_select(ch); ++ if (ALTCHKw) { ++ win_select(ch); ++ mkVIZrow1(Curwin); ++ } + break; + case 'G': + if (ALTCHKw) { +-- +1.8.3.1 + diff --git a/backport-0015-top-In-the-bye_bye-function-replace-fputs-with-the-w.patch b/backport-0015-top-In-the-bye_bye-function-replace-fputs-with-the-w.patch new file mode 100644 index 0000000..92e8059 --- /dev/null +++ b/backport-0015-top-In-the-bye_bye-function-replace-fputs-with-the-w.patch @@ -0,0 +1,35 @@ +From 0bf15c004db6a3342703a3c420a5692e376c457d Mon Sep 17 00:00:00 2001 +From: Shaohua Zhan +Date: Thu, 3 Dec 2020 10:24:09 +0800 +Subject: [PATCH] top: In the bye_bye function, replace fputs with the write + interface. + +When top calls malloc, if a signal is received, it will +call sig_endpgm to process the signal. In the bye_bye function, if the +-b option is enable, the Batch variable is set, the fputs function +will calls malloc at the same time. The malloc function is not reentrant, so +it will cause the program to crash. + +Signed-off-by: Shaohua Zhan +--- + top/top.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/top/top.c b/top/top.c +index 2ec6357..eb62001 100644 +--- a/top/top.c ++++ b/top/top.c +@@ -571,7 +571,9 @@ static void bye_bye (const char *str) { + fputs(str, stderr); + exit(EXIT_FAILURE); + } +- if (Batch) fputs("\n", stdout); ++ if (Batch) { ++ write(fileno(stdout), "\n", sizeof("\n")); ++ } + exit(EXIT_SUCCESS); + } // end: bye_bye + +-- +1.8.3.1 + diff --git a/procps-ng.spec b/procps-ng.spec index 7b7b45c..dc6c39a 100644 --- a/procps-ng.spec +++ b/procps-ng.spec @@ -1,6 +1,6 @@ Name: procps-ng Version: 3.3.16 -Release: 15 +Release: 16 Summary: Utilities that provide system information. License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+ URL: https://sourceforge.net/projects/procps-ng/ @@ -22,6 +22,8 @@ Patch0009: backport-0010-top-fix-additional-SEGVs-if-no-tasks-were-displayabl.pa Patch0010: backport-0011-pgrep-Remove-memory-leak.patch Patch0011: backport-0012-Set-TZ-to-avoid-repeated-stat-etc-localtime.patch Patch0012: backport-0013-kill-Fix-argument-handling-for-negative-PIDs.patch +Patch0013: backport-0014-top-fix-two-potential-alternate-display-mode-abends.patch +Patch0014: backport-0015-top-In-the-bye_bye-function-replace-fputs-with-the-w.patch Patch9000: feature-add-options-M-and-N-for-top.patch Patch9001: bugfix-top-exit-with-error-when-pid-overflow.patch @@ -107,6 +109,9 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof %{_mandir}/translated %changelog +* Wed Jun 30 2021 hewenliang - 3.3.16-16 +- sync patches + * Sat Feb 27 2021 hewenliang - 3.3.16-15 - sync patches -- Gitee