Jelajahi Sumber

Kernel: Return early in create_inode if name is too long

Luke 4 tahun lalu
induk
melakukan
d79194d87f
1 mengubah file dengan 3 tambahan dan 0 penghapusan
  1. 3 0
      Kernel/FileSystem/Ext2FileSystem.cpp

+ 3 - 0
Kernel/FileSystem/Ext2FileSystem.cpp

@@ -1445,6 +1445,9 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(InodeIdentifier parent_id,
     if (static_cast<const Ext2FSInode&>(*parent_inode).m_raw_inode.i_links_count == 0)
         return KResult(-ENOENT);
 
+    if (name.length() > EXT2_NAME_LEN)
+        return KResult(-ENAMETOOLONG);
+
 #ifdef EXT2_DEBUG
     dbg() << "Ext2FS: Adding inode '" << name << "' (mode " << String::format("%o", mode) << ") to parent directory " << parent_inode->identifier();
 #endif