summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMingli Yu <mingli.yu@windriver.com>2025-02-18 15:12:24 +0800
committerSteve Sakoman <steve@sakoman.com>2025-02-24 07:00:54 -0800
commit59e04621c90e886e53b9717a26a45ec36536700d (patch)
tree40ede2429e7ccb664e946241360b401e6d988bcb
parent73aef33dfa39822cd7ea2f07b9939134c015729d (diff)
downloadpoky-59e04621c90e886e53b9717a26a45ec36536700d.tar.gz
procps: replaced one use of fputs(3) with a write(2) call
This patch is ported from a merge request shown below, and the following represents the original commit text. ------------------------------------------------------ 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. (From OE-Core rev: 573f5b2d8fec9f8a4ed17e836ef3feeb6de62e5a) Signed-off-by: Shaohua Zhan <shaohua.zhan@windriver.com> ------------------------------------------------------ Reference(s): https://gitlab.com/procps-ng/procps/-/merge_requests/127 Signed-off-by: Mingli Yu <mingli.yu@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-extended/procps/procps/0001-top-fix-a-fix-for-the-bye_bye-function-merge-127.patch58
-rw-r--r--meta/recipes-extended/procps/procps/0001-top-replaced-one-use-of-fputs-3-with-a-write-2-call.patch50
-rw-r--r--meta/recipes-extended/procps/procps_3.3.17.bb2
3 files changed, 110 insertions, 0 deletions
diff --git a/meta/recipes-extended/procps/procps/0001-top-fix-a-fix-for-the-bye_bye-function-merge-127.patch b/meta/recipes-extended/procps/procps/0001-top-fix-a-fix-for-the-bye_bye-function-merge-127.patch
new file mode 100644
index 0000000000..bbc137a3d8
--- /dev/null
+++ b/meta/recipes-extended/procps/procps/0001-top-fix-a-fix-for-the-bye_bye-function-merge-127.patch
@@ -0,0 +1,58 @@
1From 37f106029975e3045b0cd779525d14c55d24b74e Mon Sep 17 00:00:00 2001
2From: Jim Warner <james.warner@comcast.net>
3Date: Mon, 21 Jun 2021 00:00:00 -0500
4Subject: [PATCH] top: fix a fix for the 'bye_bye' function (merge #127)
5
6In the merge request shown below, 1 too many bytes are
7written to stdout thus including the terminating null.
8As the cure, this commit just reduces the length by 1.
9
10[ along the way, we will remove some unneeded braces ]
11[ plus add some additional comments with attribution ]
12
13Reference(s):
14https://gitlab.com/procps-ng/procps/-/merge_requests/127
15. original merged change
16commit 0bf15c004db6a3342703a3c420a5692e376c457d
17
18Signed-off-by: Jim Warner <james.warner@comcast.net>
19
20Upstream-Status: Backport [https://gitlab.com/procps-ng/procps/-/commit/37f106029975e3045b0cd779525d14c55d24b74e]
21
22Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
23---
24 top/top.c | 14 +++++++++++---
25 1 file changed, 11 insertions(+), 3 deletions(-)
26
27diff --git a/top/top.c b/top/top.c
28index 4d9860d5..0d21a1a5 100644
29--- a/top/top.c
30+++ b/top/top.c
31@@ -569,13 +569,21 @@ static void bye_bye (const char *str) {
32 #endif // end: OFF_HST_HASH
33
34 numa_uninit();
35+
36+ /* we'll only have a 'str' if called by error_exit() |
37+ or that xalloc_our_handler() function. if we were |
38+ called from a sig_endpgm(), that parm is NULL ... | */
39 if (str) {
40 fputs(str, stderr);
41 exit(EXIT_FAILURE);
42 }
43- if (Batch) {
44- write(fileno(stdout), "\n", sizeof("\n"));
45- }
46+ /* this could happen when called from several places |
47+ including that sig_endpgm(). thus we must use an |
48+ async-signal-safe write function just in case ... |
49+ (thanks: Shaohua Zhan shaohua.zhan@windriver.com) | */
50+ if (Batch)
51+ write(fileno(stdout), "\n", sizeof("\n") - 1);
52+
53 exit(EXIT_SUCCESS);
54 } // end: bye_bye
55
56--
572.34.1
58
diff --git a/meta/recipes-extended/procps/procps/0001-top-replaced-one-use-of-fputs-3-with-a-write-2-call.patch b/meta/recipes-extended/procps/procps/0001-top-replaced-one-use-of-fputs-3-with-a-write-2-call.patch
new file mode 100644
index 0000000000..4da13df047
--- /dev/null
+++ b/meta/recipes-extended/procps/procps/0001-top-replaced-one-use-of-fputs-3-with-a-write-2-call.patch
@@ -0,0 +1,50 @@
1From 6b8980a3b6279058d727377e914cfb6439d6f178 Mon Sep 17 00:00:00 2001
2From: Shaohua Zhan <shaohua.zhan@windriver.com>
3Date: Mon, 22 Mar 2021 00:00:00 +0800
4Subject: [PATCH] top: replaced one use of fputs(3) with a write(2) call
5
6This patch is ported from a merge request shown below,
7and the following represents the original commit text.
8
9------------------------------------------------------
10top: In the bye_bye function, replace fputs with the write interface.
11
12When top calls malloc, if a signal is received, it will
13call sig_endpgm to process the signal. In the bye_bye function, if the
14-b option is enable, the Batch variable is set, the fputs function
15will calls malloc at the same time. The malloc function is not reentrant, so
16it will cause the program to crash.
17
18Signed-off-by: Shaohua Zhan <shaohua.zhan@windriver.com>
19------------------------------------------------------
20
21Reference(s):
22https://gitlab.com/procps-ng/procps/-/merge_requests/127
23
24Signed-off-by: Jim Warner <james.warner@comcast.net>
25
26Upstream-Status: Backport [https://gitlab.com/procps-ng/procps/-/commit/6b8980a3b6279058d727377e914cfb6439d6f178]
27
28Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
29---
30 top/top.c | 4 +++-
31 1 file changed, 3 insertions(+), 1 deletion(-)
32
33diff --git a/top/top.c b/top/top.c
34index f4f82be4..951c240c 100644
35--- a/top/top.c
36+++ b/top/top.c
37@@ -417,7 +417,9 @@ static void bye_bye (const char *str) {
38 fputs(str, stderr);
39 exit(EXIT_FAILURE);
40 }
41- if (Batch) fputs("\n", stdout);
42+ if (Batch) {
43+ write(fileno(stdout), "\n", sizeof("\n"));
44+ }
45 exit(EXIT_SUCCESS);
46 } // end: bye_bye
47
48--
492.34.1
50
diff --git a/meta/recipes-extended/procps/procps_3.3.17.bb b/meta/recipes-extended/procps/procps_3.3.17.bb
index bbec5a543c..131063efb9 100644
--- a/meta/recipes-extended/procps/procps_3.3.17.bb
+++ b/meta/recipes-extended/procps/procps_3.3.17.bb
@@ -18,6 +18,8 @@ SRC_URI = "git://gitlab.com/procps-ng/procps.git;protocol=https;branch=master \
18 file://0002-proc-escape.c-add-missing-include.patch \ 18 file://0002-proc-escape.c-add-missing-include.patch \
19 file://CVE-2023-4016.patch \ 19 file://CVE-2023-4016.patch \
20 file://CVE-2023-4016-2.patch \ 20 file://CVE-2023-4016-2.patch \
21 file://0001-top-replaced-one-use-of-fputs-3-with-a-write-2-call.patch \
22 file://0001-top-fix-a-fix-for-the-bye_bye-function-merge-127.patch \
21 " 23 "
22SRCREV = "19a508ea121c0c4ac6d0224575a036de745eaaf8" 24SRCREV = "19a508ea121c0c4ac6d0224575a036de745eaaf8"
23 25