Eric Blake wrote:
> The use case where I discovered this bug was with m4 1.4.11.  Compare:
> 
> mingw$ m4 .
> m4.exe: .: Permission denied
> Linux$ m4 .
> m4:/:1: Read error
> OpenBSD$ m4 . && echo done
> done
> EMX$ m4 .
> <starts trying to interpret struct dirent records as m4 input>
> 
> In an effort to unify this behavior, I was considering making m4 1.4.12
> pre-reject directories with EISDIR (POSIX allows this, since directories
> are not text files, and m4 is only required to operate on text files),
> while remembering that doing stat() prior to fopen() is racy.

Then I would split the fopen() call into open() + fdopen(), and use fstat()
between the two operations to detect the case of a directory. This is not
racy, and it never runs into the EACCES case on mingw.

Bruno



Reply via email to