diff options
author | Andreas Kling <kling@serenityos.org> | 2020-10-22 18:59:00 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-22 18:59:00 +0200 |
commit | a316ca0e0df40f9d08c566fc212517a9c54fb22e (patch) | |
tree | e75ad66bc76228adce4b4489e5326b8c579afddc | |
parent | e590c53a1dcdf19b4e9b1fcadc64b2ad5c657630 (diff) | |
download | serenity-a316ca0e0df40f9d08c566fc212517a9c54fb22e.zip |
TmpFS: Don't allow file names longer than NAME_MAX
Fixes #3636.
-rw-r--r-- | Kernel/FileSystem/TmpFS.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
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 <Kernel/FileSystem/TmpFS.h> #include <Kernel/Process.h> #include <Kernel/Thread.h> +#include <LibC/limits.h> 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<TmpFSInode&>(child) }); did_add_child(child.identifier()); return KSuccess; |