[Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available

keith.marshall at mailinator dot com gcc-bugzilla@gcc.gnu.org
Sun Jul 19 20:50:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #5 from Keith Marshall <keith.marshall at mailinator dot com> ---
(In reply to kargl from comment #4)
> Update title.  The code in question is
> 
> #ifdef HAVE_UMASK
>   /* Temporarily set the umask such that the file has 0600 permissions.  */
>   mode_mask = umask (S_IXUSR | S_IRWXG | S_IRWXO);
> #endif
> 
> MinGW appears to define HAVE_UMASK, but MinGW seems to lack
> a correctly written umask(3).

MinGW inherits its umask() implementation from Microsoft, in the shape of
whatever MSVCRT.DLL provides; (and yes, at one time Microsoft decided to rename
their umask() implementation to _umask(), but MinGW has always mapped those
renames back to their originals, for backwards compatibility). So, the bug is
that you gratuitously assume that any umask() implementation should conform to
POSIX, even when the platform is not POSIX. IF you aim to support non-POSIX
platforms, (as you do with the mingw32 target), you must be prepared to handle
non-POSIX implementations, such as this umask() --> _umask(), which is
documented at https://msdn.microsoft.com/en-us/library/5axxx3be.aspx



More information about the Gcc-bugs mailing list