From 60af7f327e63809115ac796bcd815894556c4c4c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 19 Jan 2025 12:51:18 +0200 Subject: [PATCH] Fix visiting files in /proc/ directory * src/fileio.c (Finsert_file_contents): Treat regular files whose size is reported as zero as if they were special files. (Bug#75569) (cherry picked from commit 26c9fbc94dae34fc119828661c71242d80bb33c5) --- src/fileio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index db7c491e1a1..bf80d71ab59 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4747,10 +4747,11 @@ by calling `format-decode', which see. */) goto handled; } - if (seekable || !NILP (end)) + /* Don't believe st.st_size if it is zero. */ + if ((regular && st.st_size > 0) || (!regular && seekable) || !NILP (end)) total = end_offset - beg_offset; else - /* For a special file, all we can do is guess. */ + /* For a special file that is not seekable, all we can do is guess. */ total = READ_BUF_SIZE; if (NILP (visit) && total > 0) -- 2.39.5