Forráskód Böngészése

Kernel: Make custody_for_dirfd() fail on files other than directories

Andreas Kling 2 éve
szülő
commit
f0c9c5e076
1 módosított fájl, 5 hozzáadás és 4 törlés
  1. 5 4
      Kernel/Process.cpp

+ 5 - 4
Kernel/Process.cpp

@@ -1084,11 +1084,12 @@ ErrorOr<NonnullRefPtr<Custody>> Process::custody_for_dirfd(int dirfd)
 {
 {
     if (dirfd == AT_FDCWD)
     if (dirfd == AT_FDCWD)
         return current_directory();
         return current_directory();
-
-    auto base_description = TRY(open_file_description(dirfd));
-    if (!base_description->custody())
+    auto description = TRY(open_file_description(dirfd));
+    if (!description->custody())
         return EINVAL;
         return EINVAL;
-    return *base_description->custody();
+    if (!description->is_directory())
+        return ENOTDIR;
+    return *description->custody();
 }
 }
 
 
 SpinlockProtected<NonnullOwnPtr<KString>, LockRank::None> const& Process::name() const
 SpinlockProtected<NonnullOwnPtr<KString>, LockRank::None> const& Process::name() const