Subject: bug#75569: 30.0.93; Large /proc/* file are read incompletely

From: Eli Zaretskii <[email-masked]>
Date: Wed, 15 Jan 2025 22:07:02 +0200

> From: Juri Linkov <[email-masked]>
> Cc: Paul Eggert <[email-masked]>,  [email-masked],
>   [email-masked]
> Date: Wed, 15 Jan 2025 19:08:03 +0200
> 
> > But maybe commits 8650b3308dd and/or 3fb2c174d3a7 broke that later?
> 
> I confirm that reverting 8650b3308dd fixes it again after removing 'seekable'.

Thanks.  Can you try the patch below?

> > The /proc/cpuinfo file on the system to which I have access is smaller
> > than 16KB, so could someone who can access a larger cpuinfo file
> > please see if those commits broke the fix, or maybe bisect?
> 
> To be able to test it you need at least 16 cpu cores.  If this is
> not feasible, a simpler way would be just to try on another file
> such as /proc/crypto.

/proc/crypto here is also less than 16KB, so I still cannot test.

diff --git a/src/fileio.c b/src/fileio.c
index db7c491..a296970 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4747,7 +4747,7 @@ DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents,
       goto handled;
     }
 
-  if (seekable || !NILP (end))
+  if ((seekable && st.size > 0) || !NILP (end))
     total = end_offset - beg_offset;
   else
     /* For a special file, all we can do is guess.  */