On Jul 14 2025, Chet Ramey wrote:

> One of the assumptions bash makes is that when the kernel tells it the size
> of a regular file using stat(2), it's telling the truth, and that reading
> fewer bytes than that when asking for the entire file indicates some kind
> of problem.

That's a TOCTOU race.  The file can change any time between stat and
read.  The only truth is that when read returns an error, there is an
error.

> Yes. It seems like that assumption isn't valid on Linux.

It isn't valid anywhere.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

Reply via email to