glocalfileoutputstream: Only pass file mode, not type, to chmod()

chmod() technically only accepts file modes, not the file type and mode
as returned by stat(). Filter by `S_IFMT` to avoid sending the file
type (regular file, directory, symbolic link, etc.).

In practice, chmod() ignores anything except the file mode, but we might
as well comply with the specification.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2019-09-27 17:33:01 +01:00
parent 674ba78f12
commit 5dd5269126

View File

@ -979,7 +979,7 @@ handle_overwrite_open (const char *filename,
fchown (tmpfd, original_stat.st_uid, original_stat.st_gid) == -1 ||
#endif
#ifdef HAVE_FCHMOD
fchmod (tmpfd, original_stat.st_mode) == -1 ||
fchmod (tmpfd, original_stat.st_mode & ~S_IFMT) == -1 ||
#endif
0
)