From a316ca0e0df40f9d08c566fc212517a9c54fb22e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 22 Oct 2020 18:59:00 +0200 Subject: [PATCH] TmpFS: Don't allow file names longer than NAME_MAX Fixes #3636. --- Kernel/FileSystem/TmpFS.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Kernel/FileSystem/TmpFS.cpp b/Kernel/FileSystem/TmpFS.cpp index 2109cfce2a..54f2b77d09 100644 --- a/Kernel/FileSystem/TmpFS.cpp +++ b/Kernel/FileSystem/TmpFS.cpp @@ -27,6 +27,7 @@ #include #include #include +#include namespace Kernel { @@ -297,6 +298,9 @@ KResult TmpFSInode::add_child(Inode& child, const StringView& name, mode_t) ASSERT(is_directory()); ASSERT(child.fsid() == fsid()); + if (name.length() > NAME_MAX) + return KResult(-ENAMETOOLONG); + m_children.set(name, { name, static_cast(child) }); did_add_child(child.identifier()); return KSuccess;