From d6494a98f0219643ce7164ecd6ec1ae86b90714f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E8=BF=9B?= Date: Fri, 6 Jun 2025 06:42:16 +0000 Subject: [PATCH] !1 sync community bugfix patches sync community bugfix patches: 1.procps-ng: check for null on escape source and Use u/gid if pwcache returns empty user/group 2.ps: mv check for null from escape_str_utf8 to escape_str --- ...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 ++++++++++++++++ procps-ng.spec | 8 +++- 4 files changed, 127 insertions(+), 1 deletion(-) 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 backport-0003-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/backport-0003-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.patch b/backport-0003-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.patch new file mode 100644 index 0000000..7b2eff8 --- /dev/null +++ b/backport-0003-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 + diff --git a/procps-ng.spec b/procps-ng.spec index 4a0bac7..16d9306 100644 --- a/procps-ng.spec +++ b/procps-ng.spec @@ -1,6 +1,6 @@ Name: procps-ng Version: 4.0.4 -Release: 6 +Release: 7 Summary: Utilities that provide system information. License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+ URL: https://sourceforge.net/projects/procps-ng/ @@ -19,6 +19,9 @@ Patch7: openeuler-uptime-Fix-uptime-return-0-user-when-systemd-pam-is-.patch 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 +Patch11: backport-0001-library-Use-u-gid-if-pwcache-returns-empty-user-grou.patch +Patch12: backport-0002-ps-check-for-null-on-escape-source.patch +Patch13: backport-0003-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.patch BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel @@ -101,6 +104,9 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof %{_mandir}/man* %changelog +* Fri Jun 6 2025 Zhu Jin - 4.0.4-7 +- top: Synchronize community bugfix patches + * Tue Jun 25 2024 Liu Chao - 4.0.4-6 - top: adapt to guest/total tics change, api -- Gitee