summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-02-05 20:03:49 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-05 21:23:11 +0100
commit4c0707e56c207bf5deb9e322efa61cb9de3b862a (patch)
treeb4640de1ae0b65308682429a1ad81ea050f51e3e /Kernel/FileSystem
parentd164f89ada92529f7d03d5bfddbabbbc4ea4777c (diff)
downloadserenity-4c0707e56c207bf5deb9e322efa61cb9de3b862a.zip
Kernel: Don't create a zero-length VLA in Ext2FS block list walk
Found by KUBSAN :^)
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp
index 7ed5212404..7ae70fc106 100644
--- a/Kernel/FileSystem/Ext2FileSystem.cpp
+++ b/Kernel/FileSystem/Ext2FileSystem.cpp
@@ -501,6 +501,8 @@ Vector<Ext2FS::BlockIndex> Ext2FS::block_list_for_inode_impl(const ext2_inode& e
if (include_block_list_blocks)
add_block(array_block_index);
auto count = min(blocks_remaining, entries_per_block);
+ if (!count)
+ return;
u32 array[count];
auto buffer = UserOrKernelBuffer::for_kernel_buffer((u8*)array);
auto result = read_block(array_block_index, &buffer, sizeof(array), 0);