sort: don't trust st_size on /proc files

This commit is contained in:
markeryang 2024-06-13 02:53:56 +00:00
parent 4238c0bd6a
commit ad5eab3f81
2 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,32 @@
From 8ff3903281e03d36dd1aa2a202a56f38af726d91 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
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): Dont 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

View File

@ -1,6 +1,6 @@
Name: coreutils
Version: 8.32
Release: 12
Release: 13
License: GPLv3+
Summary: A set of basic GNU tools commonly used in shell scripts
Url: https://www.gnu.org/software/coreutils/
@ -51,6 +51,7 @@ Patch33: backport-fix-mem-leaks.patch
Patch34: backport-coverity-utimens.patch
Patch35: backport-fuse-portal.patch
Patch36: backport-expr-unmatched-par.patch
Patch37: backport-sort-don-t-trust-st_size-on-proc-files.patch
Conflicts: filesystem < 3
# To avoid clobbering installs
@ -169,6 +170,9 @@ fi
%{_mandir}/man*/*
%changelog
* Thu Jun 13 2024 yanglongkang <yanglongkang@h-partners.com> - 8.32-13
- sort: don't trust st_size on /proc files
* Fri Mar 22 2024 cenhuilin <cenhuilin@kylinos.cn> - 8.32-12
- sync patches from community
- add backport-coverity-utimens.patch