Переглянути джерело

Kernel: Add file permission checks to link() syscall.

Also use the new name, not the old name, for the new link, duh.
Andreas Kling 6 роки тому
батько
коміт
19acb2baf7
1 змінених файлів з 5 додано та 1 видалено
  1. 5 1
      Kernel/VirtualFileSystem.cpp

+ 5 - 1
Kernel/VirtualFileSystem.cpp

@@ -350,8 +350,12 @@ bool VFS::link(const String& old_path, const String& new_path, Inode& base, int&
         error = -EROFS;
         error = -EROFS;
         return false;
         return false;
     }
     }
+    if (!parent_inode->metadata().may_write(*current)) {
+        error = -EACCES;
+        return false;
+    }
 
 
-    if (!parent_inode->add_child(old_inode->identifier(), FileSystemPath(old_path).basename(), 0, error))
+    if (!parent_inode->add_child(old_inode->identifier(), FileSystemPath(new_path).basename(), 0, error))
         return false;
         return false;
     error = 0;
     error = 0;
     return true;
     return true;