From c1967b7d806ffdfe97761c9ddc99e6c238d38f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E8=BF=9B?= Date: Thu, 5 Jun 2025 11:41:53 +0000 Subject: [PATCH 1/2] sync bugfix patches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 朱进 --- ...d-if-pwcache-returns-empty-user-grou.patch | 46 +++++++++++++++++++ ...2-ps-check-for-null-on-escape-source.patch | 34 ++++++++++++++ ...null-from-escape_str_utf8-to-escape_.patch | 40 ++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 backport-0001-library-Use-u-gid-if-pwcache-returns-empty-user-grou.patch create mode 100644 backport-0002-ps-check-for-null-on-escape-source.patch create mode 100644 huawei-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.patch diff --git a/backport-0001-library-Use-u-gid-if-pwcache-returns-empty-user-grou.patch b/backport-0001-library-Use-u-gid-if-pwcache-returns-empty-user-grou.patch new file mode 100644 index 0000000..82903a6 --- /dev/null +++ b/backport-0001-library-Use-u-gid-if-pwcache-returns-empty-user-grou.patch @@ -0,0 +1,46 @@ +From 681e55bc03d99d9542a675c2a0509d6c5c149358 Mon Sep 17 00:00:00 2001 +From: Craig Small +Date: Thu, 24 Apr 2025 20:50:36 +1000 +Subject: [PATCH 1/2] library: Use u/gid if pwcache returns empty user/group + +pwcache_get_user returns the uid if getpwuid fails or the username is +too long. However if getpwuid succeeds but there is no usename then +we get a blank username. Instead use the uid fallback. + +Same for pwcache_get_group + +May fix #380 + +Reference:https://gitlab.com/procps-ng/procps/-/commit/681e55bc03d99d9542a675c2a0509d6c5c149358 +Conflict: adapt context, add ; after ERRname + +Signed-off-by: Craig Small +--- + library/pwcache.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/library/pwcache.c b/library/pwcache.c +index 9293c002..2f1e0e78 100644 +--- a/library/pwcache.c ++++ b/library/pwcache.c +@@ -61,7 +61,7 @@ char *pwcache_get_user(uid_t uid) { + return ERRname; + (*p)->uid = uid; + pw = getpwuid(uid); +- if(!pw || strlen(pw->pw_name) >= P_G_SZ) ++ if(!pw || strlen(pw->pw_name) >= P_G_SZ || pw->pw_name[0] == '\0') + sprintf((*p)->name, "%u", uid); + else + strcpy((*p)->name, pw->pw_name); +@@ -90,7 +90,7 @@ char *pwcache_get_group(gid_t gid) { + return ERRname;; + (*g)->gid = gid; + gr = getgrgid(gid); +- if (!gr || strlen(gr->gr_name) >= P_G_SZ) ++ if (!gr || strlen(gr->gr_name) >= P_G_SZ || gr->gr_name[0] == '\0') + sprintf((*g)->name, "%u", gid); + else + strcpy((*g)->name, gr->gr_name); +-- +2.23.0 + diff --git a/backport-0002-ps-check-for-null-on-escape-source.patch b/backport-0002-ps-check-for-null-on-escape-source.patch new file mode 100644 index 0000000..08e1b35 --- /dev/null +++ b/backport-0002-ps-check-for-null-on-escape-source.patch @@ -0,0 +1,34 @@ +From 3484ac479ed586fa7d801e20fded3cbfee92ffad Mon Sep 17 00:00:00 2001 +From: Craig Small +Date: Thu, 24 Apr 2025 20:58:50 +1000 +Subject: [PATCH 2/2] ps: check for null on escape source + +return 0 if source string for escape is null + +May fix #380 + +Reference:https://gitlab.com/procps-ng/procps/-/commit/3484ac479ed586fa7d801e20fded3cbfee92ffad +Conflict:NA + +Signed-off-by: Craig Small +--- + src/ps/output.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/ps/output.c b/src/ps/output.c +index ba52d14e..4d9b690c 100644 +--- a/src/ps/output.c ++++ b/src/ps/output.c +@@ -157,6 +157,9 @@ static int escape_str_utf8 (char *dst, const char *src, int bufsize, int *maxcel + + SECURE_ESCAPE_ARGS(dst, bufsize, *maxcells); + ++ if (NULL == src) ++ return 0; ++ + memset(&s, 0, sizeof (s)); + + for(;;) { +-- +2.23.0 + diff --git a/huawei-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.patch b/huawei-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.patch new file mode 100644 index 0000000..7b2eff8 --- /dev/null +++ b/huawei-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.patch @@ -0,0 +1,40 @@ +From a81ecea2821302e6f612bc889a001713794dc556 Mon Sep 17 00:00:00 2001 +From: Liu Chao +Date: Tue, 13 May 2025 12:41:07 +0300 +Subject: [PATCH] ps: mv check for null from escape_str_utf8 to escape_str + +https://gitlab.com/procps-ng/procps/-/issues/380 coredump in escape_str +check in escape_str_utf8 cannot fix it. + +Signed-off-by: Liu Chao +--- + src/ps/output.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/ps/output.c b/src/ps/output.c +index 4d9b690c..bfb1bb08 100644 +--- a/src/ps/output.c ++++ b/src/ps/output.c +@@ -157,9 +157,6 @@ static int escape_str_utf8 (char *dst, const char *src, int bufsize, int *maxcel + + SECURE_ESCAPE_ARGS(dst, bufsize, *maxcells); + +- if (NULL == src) +- return 0; +- + memset(&s, 0, sizeof (s)); + + for(;;) { +@@ -233,6 +230,9 @@ static int escape_str (char *dst, const char *src, int bufsize, int *maxcells) { + "????????????????????????????????"; + static int utf_init=0; + ++ if (NULL == src) ++ return 0; ++ + if(utf_init==0){ + /* first call -- check if UTF stuff is usable */ + char *enc = nl_langinfo(CODESET); +-- +2.23.0 + -- Gitee From b7cc374c9d3e27ad0591e873eb5378ca22798519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E8=BF=9B?= Date: Thu, 5 Jun 2025 11:44:08 +0000 Subject: [PATCH 2/2] sync bugfix patches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 朱进 --- procps-ng.spec | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/procps-ng.spec b/procps-ng.spec index 4a0bac7..0f39bf3 100644 --- a/procps-ng.spec +++ b/procps-ng.spec @@ -20,6 +20,11 @@ Patch8: openeuler-w-Fix-w-print-0-user-when-systemd-pam-is-not-install.patch Patch9: backport-library-implement-guest-total-tics-change-stat-api.patch Patch10: backport-top-adapt-to-that-guest-total-tics-change-stat-api.patch +Patch6000: backport-0001-library-Use-u-gid-if-pwcache-returns-empty-user-grou.patch +Patch6001: backport-0002-ps-check-for-null-on-escape-source.patch + +Patch9001: huawei-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.patch + BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel Provides: procps = %{version}-%{release} -- Gitee