TmpFS: Don't allow file names longer than NAME_MAX

Fixes #3636.
This commit is contained in:
Andreas Kling 2020-10-22 18:59:00 +02:00
parent e590c53a1d
commit a316ca0e0d
Notes: sideshowbarker 2024-07-19 01:48:08 +09:00

View File

@ -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;