Skip to content

Commit

Permalink
FileSystem: Only retrieve inode metadata once in VFS::chown().
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jun 2, 2019
1 parent 1876606 commit aa35c08
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Kernel/FileSystem/VirtualFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,13 @@ KResult VFS::chown(StringView path, uid_t a_uid, gid_t a_gid, Custody& base)
if (inode.fs().is_readonly())
return KResult(-EROFS);

if (current->process().euid() != inode.metadata().uid && !current->process().is_superuser())
auto metadata = inode.metadata();

if (current->process().euid() != metadata.uid && !current->process().is_superuser())
return KResult(-EPERM);

uid_t new_uid = inode.metadata().uid;
gid_t new_gid = inode.metadata().gid;
uid_t new_uid = metadata.uid;
gid_t new_gid = metadata.gid;

if (a_uid != (uid_t)-1) {
if (current->process().euid() != a_uid && !current->process().is_superuser())
Expand Down

0 comments on commit aa35c08

Please sign in to comment.