summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/FileSystem.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-10 21:04:27 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-10 21:04:27 +0200
commitb9be6b7bb4866cf73d48f64a6a0b80164a22a550 (patch)
tree13013b0f4e0faef108d4a9b8548278a4b5b0e329 /Kernel/FileSystem/FileSystem.cpp
parentada1f504fd1ec1797515267f69029df6ea113f0f (diff)
downloadserenity-b9be6b7bb4866cf73d48f64a6a0b80164a22a550.zip
Ext2FS: Trying to create a too-long directory entry should ENAMETOOLONG
Also added some assertions to DirectoryEntry in case someone tries to instantiate them with names that would overflow the name buffer. DirectoryEntry is a crappy data structure, and the name buffer is also crappy. Added a FIXME about replacing it with something nicer. Before this patch, the DirectoryEntry::name buffer would overflow if you did "touch extremely-long-file-name". Duh. Fixes #538.
Diffstat (limited to 'Kernel/FileSystem/FileSystem.cpp')
-rw-r--r--Kernel/FileSystem/FileSystem.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/Kernel/FileSystem/FileSystem.cpp b/Kernel/FileSystem/FileSystem.cpp
index c0c612c9c9..bae0038a52 100644
--- a/Kernel/FileSystem/FileSystem.cpp
+++ b/Kernel/FileSystem/FileSystem.cpp
@@ -41,6 +41,7 @@ FS::DirectoryEntry::DirectoryEntry(const char* n, InodeIdentifier i, u8 ft)
, inode(i)
, file_type(ft)
{
+ ASSERT(name_length < (int)sizeof(name));
memcpy(name, n, name_length);
name[name_length] = '\0';
}
@@ -50,6 +51,7 @@ FS::DirectoryEntry::DirectoryEntry(const char* n, int nl, InodeIdentifier i, u8
, inode(i)
, file_type(ft)
{
+ ASSERT(name_length < (int)sizeof(name));
memcpy(name, n, nl);
name[nl] = '\0';
}