From 8ad07cd19e769e13cbe695fbc2014e1267cdd549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E8=BF=9B?= Date: Fri, 6 Jun 2025 08:15:57 +0000 Subject: [PATCH] !4 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 | 48 +++++++++++++++++++ ...6-ps-check-for-null-on-escape-source.patch | 34 +++++++++++++ ...null-from-escape_str_utf8-to-escape_.patch | 44 +++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 backport-0015-library-Use-u-gid-if-pwcache-returns-empty-user-grou.patch create mode 100644 backport-0016-ps-check-for-null-on-escape-source.patch create mode 100644 backport-0017-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.patch diff --git a/backport-0015-library-Use-u-gid-if-pwcache-returns-empty-user-grou.patch b/backport-0015-library-Use-u-gid-if-pwcache-returns-empty-user-grou.patch new file mode 100644 index 0000000..854541b --- /dev/null +++ b/backport-0015-library-Use-u-gid-if-pwcache-returns-empty-user-grou.patch @@ -0,0 +1,48 @@ +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 +Conflict: Change library/pwcache.c to proc/pwcache.c. +Conflict: Adapt context, such as "return ERRname;" -> "*p = (struct pwbuf *) xmalloc(sizeof(struct pwbuf));". + +Signed-off-by: Craig Small +--- + proc/pwcache.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/proc/pwcache.c b/proc/pwcache.c +index 9293c002..2f1e0e78 100644 +--- a/proc/pwcache.c ++++ b/proc/pwcache.c +@@ -61,7 +61,7 @@ char *pwcache_get_user(uid_t uid) { + *p = (struct pwbuf *) xmalloc(sizeof(struct pwbuf)); + (*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) { + *g = (struct grpbuf *) xmalloc(sizeof(struct grpbuf)); + (*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-0016-ps-check-for-null-on-escape-source.patch b/backport-0016-ps-check-for-null-on-escape-source.patch new file mode 100644 index 0000000..7dca264 --- /dev/null +++ b/backport-0016-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:Change src/ps/output.c to proc/escape.c. + +Signed-off-by: Craig Small +--- + proc/escape.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/proc/escape.c b/proc/escape.c +index ba52d14e..4d9b690c 100644 +--- a/proc/escape.c ++++ b/proc/escape.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-0017-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.patch b/backport-0017-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.patch new file mode 100644 index 0000000..ac7fdd1 --- /dev/null +++ b/backport-0017-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.patch @@ -0,0 +1,44 @@ +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. + +Reference:https://gitlab.com/procps-ng/procps/-/merge_requests/255/diffs?commit_id=a81ecea2821302e6f612bc889a001713794dc556 +Conflict:NA + +Signed-off-by: Liu Chao +--- + proc/escape.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/proc/escape.c b/proc/escape.c +index 4d9b690c..bfb1bb08 100644 +--- a/proc/escape.c ++++ b/proc/escape.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) { + unsigned char c; + int my_cells = 0; + int my_bytes = 0; ++ if (NULL == src) ++ return 0; ++ + const char codes[] = + "Z..............................." + "||||||||||||||||||||||||||||||||" +-- +2.23.0 + + -- Gitee