From d363d5e91584b92dc1506a871c1421980e7b2f77 Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 2 Jul 2023 17:30:14 +0200 Subject: [PATCH] kernel/ext2: Make sure we don't crash when accessing the last inode --- kernel/src/fs/ext2/FileSystem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/src/fs/ext2/FileSystem.cpp b/kernel/src/fs/ext2/FileSystem.cpp index 31a80ec6..9735f3a9 100644 --- a/kernel/src/fs/ext2/FileSystem.cpp +++ b/kernel/src/fs/ext2/FileSystem.cpp @@ -27,7 +27,8 @@ namespace Ext2 Result> FileSystem::find_inode_by_number(ino_t inum, bool initialize_dir_now) { - check(inum < m_superblock.nr_inodes); + // Inode numbers start at 1. + check(inum <= m_superblock.nr_inodes); auto maybe_inode = m_inode_cache.try_get(inum); if (maybe_inode.has_value()) return maybe_inode.value();