From e30b3b65e67338b6ced3c282d8dec225b98d1fa7 Mon Sep 17 00:00:00 2001 From: yinyongkang Date: Mon, 25 Aug 2025 16:00:00 +0800 Subject: [PATCH] library: internal expand buffer for stat_fd --- ...y-internal-expand-buffer-for-stat-fd.patch | 41 +++++++++++++++++++ procps-ng.spec | 6 ++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 backport-0004-library-internal-expand-buffer-for-stat-fd.patch diff --git a/backport-0004-library-internal-expand-buffer-for-stat-fd.patch b/backport-0004-library-internal-expand-buffer-for-stat-fd.patch new file mode 100644 index 0000000..fa314c5 --- /dev/null +++ b/backport-0004-library-internal-expand-buffer-for-stat-fd.patch @@ -0,0 +1,41 @@ +From 9902b5ba4d09d4ba5dbdf81e9dc1f56c47e04e05 Mon Sep 17 00:00:00 2001 +From: Craig Small +Date: Mon, 17 Mar 2025 18:49:45 +1100 +Subject: [PATCH] library: internal expand buffer for stat_fd + +The inline function stat_fd is given a buffer up to PROCPATHLEN +size and then it snprintfs this plus 3 more characters into the +same length buffer. Make the second buffer 3 characters long so +there can be no truncation (and complaints from the compilier) + +library/readproc.c: In function 'simple_readproc': +library/readproc.c:1184:35: warning: '/fd' directive output may be truncated writing 3 bytes into a region of size between 1 and 64 [-Wformat-truncation=] + 1184 | snprintf(buf, sizeof(buf), "%s/fd", path); + | ^~~ +In function 'stat_fd', + inlined from 'simple_readproc' at library/readproc.c:1339:9: +library/readproc.c:1184:5: note: 'snprintf' output between 4 and 67 bytes into a destination of size 64 + 1184 | snprintf(buf, sizeof(buf), "%s/fd", path); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Signed-off-by: Craig Small +--- + library/readproc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/library/readproc.c b/library/readproc.c +index 1197a8b2..b4fdd63d 100644 +--- a/library/readproc.c ++++ b/library/readproc.c +@@ -1177,7 +1177,7 @@ static void autogroup_fill (const char *path, proc_t *p) { + + + static inline void stat_fd (const char *path, proc_t *p) { +- char buf[PROCPATHLEN]; ++ char buf[PROCPATHLEN+3]; // +"/fd" + struct stat sb; + + p->fds = 0; +-- +GitLab + diff --git a/procps-ng.spec b/procps-ng.spec index fcd8de4..0dce518 100644 --- a/procps-ng.spec +++ b/procps-ng.spec @@ -1,6 +1,6 @@ Name: procps-ng Version: 4.0.5 -Release: 2 +Release: 3 Summary: Utilities that provide system information. License: GPL-2.0-or-later AND LGPL-2.0-or-later AND LGPL-2.1-or-later URL: https://sourceforge.net/projects/procps-ng/ @@ -15,6 +15,7 @@ Patch3: backport-fix-breakage-in-unhex.patch Patch4: backport-0001-library-Use-u-gid-if-pwcache-returns-empty-user-grou.patch Patch5: backport-0002-ps-check-for-null-on-escape-source.patch Patch6: backport-0003-ps-mv-check-for-null-from-escape_str_utf8-to-escape_.patch +Patch7: backport-0004-library-internal-expand-buffer-for-stat-fd.patch BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel @@ -92,6 +93,9 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof %{_mandir}/man?/* %changelog +* Mon Aug 25 2025 yinyongkang - 4.0.5-3 +- library: internal expand buffer for stat_fd + * Sat Jun 7 2025 Zhu Jin - 4.0.5-2 - top: Synchronize community bugfix patches -- Gitee