diff --git a/fs/vfs/fs_chstat.c b/fs/vfs/fs_chstat.c index 8b019fc80f..594e46da2d 100644 --- a/fs/vfs/fs_chstat.c +++ b/fs/vfs/fs_chstat.c @@ -118,11 +118,6 @@ static int chstat(FAR const char *path, /* Adjust and check buf and flags */ - if ((flags & CH_STAT_MODE) && (buf->st_mode & ~0177777)) - { - goto errout; - } - if ((flags & CH_STAT_UID) && buf->st_uid == -1) { flags &= ~CH_STAT_UID; @@ -210,7 +205,7 @@ int chmod(FAR const char *path, mode_t mode) { struct stat buf; - buf.st_mode = mode; + buf.st_mode = mode & 0777; return chstat(path, &buf, CH_STAT_MODE, 1); } @@ -236,7 +231,7 @@ int lchmod(FAR const char *path, mode_t mode) { struct stat buf; - buf.st_mode = mode; + buf.st_mode = mode & 0777; return chstat(path, &buf, CH_STAT_MODE, 0); } diff --git a/fs/vfs/fs_fchstat.c b/fs/vfs/fs_fchstat.c index ff65818b6f..a495201787 100644 --- a/fs/vfs/fs_fchstat.c +++ b/fs/vfs/fs_fchstat.c @@ -114,11 +114,6 @@ int file_fchstat(FAR struct file *filep, FAR struct stat *buf, int flags) /* Adjust and check buf and flags */ - if ((flags & CH_STAT_MODE) && (buf->st_mode & ~0177777)) - { - return -EINVAL; - } - if ((flags & CH_STAT_UID) && buf->st_uid == -1) { flags &= ~CH_STAT_UID; @@ -224,7 +219,7 @@ int fchmod(int fd, mode_t mode) { struct stat buf; - buf.st_mode = mode; + buf.st_mode = mode & 0777; return fchstat(fd, &buf, CH_STAT_MODE); }