From fbd4aceb042a46fa91b82c74d4d1459fe87ac52e Mon Sep 17 00:00:00 2001 From: markeryang Date: Wed, 12 Jun 2024 07:01:52 +0000 Subject: [PATCH] sort: don't trust st_size on /proc files --- ...rt-don-t-trust-st_size-on-proc-files.patch | 32 +++++++++++++++++++ coreutils.spec | 6 +++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 backport-sort-don-t-trust-st_size-on-proc-files.patch diff --git a/backport-sort-don-t-trust-st_size-on-proc-files.patch b/backport-sort-don-t-trust-st_size-on-proc-files.patch new file mode 100644 index 0000000..210774e --- /dev/null +++ b/backport-sort-don-t-trust-st_size-on-proc-files.patch @@ -0,0 +1,32 @@ +From 8ff3903281e03d36dd1aa2a202a56f38af726d91 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Sat, 6 Apr 2024 15:17:14 -0700 +Subject: [PATCH] =?UTF-8?q?sort:=20don=E2=80=99t=20trust=20st=5Fsize=20on?= + =?UTF-8?q?=20/proc=20files?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Problem and fix reported by Takashi Kusumi in: +https://bugs.gnu.org/70231 +* src/sort.c (sort_buffer_size): Don’t trust st_size == 0. +--- + src/sort.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/sort.c b/src/sort.c +index e779845..b983ca2 100644 +--- a/src/sort.c ++++ b/src/sort.c +@@ -1538,7 +1538,7 @@ sort_buffer_size (FILE *const *fps, size_t nfps, + != 0) + sort_die (_("stat failed"), files[i]); + +- if (S_ISREG (st.st_mode)) ++ if (usable_st_size (&st) && 0 < st.st_size) + file_size = st.st_size; + else + { +-- +2.27.0 + diff --git a/coreutils.spec b/coreutils.spec index a406eb3..acdc6e1 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,6 +1,6 @@ Name: coreutils Version: 9.4 -Release: 4 +Release: 5 License: GPLv3+ Summary: A set of basic GNU tools commonly used in shell scripts Url: https://www.gnu.org/software/coreutils/ @@ -24,6 +24,7 @@ Patch9: backport-coreutils-i18n.patch patch10: backport-CVE-2024-0684-split-do-not-shrink-hold-buffer.patch patch11: test-skip-overlay-filesystem-because-of-no-inotify_add_watch.patch patch12: fix-coredump-if-enable-systemd.patch +patch13: backport-sort-don-t-trust-st_size-on-proc-files.patch %ifarch sw_64 Patch9001: coreutils-9.0-sw.patch %endif @@ -158,6 +159,9 @@ fi %{_mandir}/man*/* %changelog +* Wed Jun 12 2024 yanglongkang - 9.4-5 +- sort: don't trust st_size on /proc files + * Tue Apr 16 2024 Wenlong Zhang - 9.4-4 - delete strace for loongarch64 -- Gitee