From 064e46e581e682ca8e99e2771494c634bffcedb4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 3 Jan 2020 02:23:50 +0100 Subject: [PATCH] Kernel: Don't allow open() with (O_CREAT | O_DIRECTORY) --- Kernel/FileSystem/VirtualFileSystem.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index d91f558878..64317dec64 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -185,6 +185,9 @@ KResultOr VFS::lookup_metadata(StringView path, Custody& base, in KResultOr> VFS::open(StringView path, int options, mode_t mode, Custody& base) { + if ((options & O_CREAT) && (options & O_DIRECTORY)) + return KResult(-EINVAL); + RefPtr parent_custody; auto custody_or_error = resolve_path(path, base, &parent_custody, options); if (options & O_CREAT) {