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

From: Paul Eggert <[email-masked]>
Date: Wed, 15 Jan 2025 22:58:31 -0800

On 2025-01-15 22:18, Eli Zaretskii wrote:

> So you are saying that the condition should be
> 
>     if ((regular && st.st_size > 0) || seekable || !NILP (end))

regular implies seekable, so that doesn't look right either. I was 
thinking that rather than replace "seekable" with "(seekable && st.size 
 > 0)" or with "(regular && st.st_size > 0) || seekable", one should 
replace "seekable" with "(regular && st.st_size > 0)".

> AFAIU, the additional conditions are not needed for these two uses,
> because:
> 
>    . 'total' is already computed correctly at that point for the
>      regular zero-size files
>    . only non-regular files can be !seekable
> 
> Or am I missing something?

You've looked it more carefully than I. All I was thinking is that if 
'total' was guessed to be READ_BUF_SIZE earlier, it's still a guess here.

Anyway, I suppose it doesn't matter much, as 'total' is a guess 
regardless of how it's computed. Even a regular file with nonzero size 
can change size before we read it.

There's another thing. On some platforms these /proc regular files have 
nonzero size. On at least one of these platforms (Solaris) the size is 
accurate (though it may change at any time); on others, I vaguely recall 
that it's a small nonzero fixed size (I don't remember which systems do 
that, unfortunately).