sort: don’t trust st_size on /proc files

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.
This commit is contained in:
Paul Eggert 2024-04-06 15:17:14 -07:00
parent ac6b8d8224
commit 8ff3903281

View File

@ -1539,7 +1539,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
{