From 9ecd156622b79a7dd0a3d72c2e2d1c191871d9ca Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 22 Mar 2024 11:21:03 +0200 Subject: [PATCH] Kenrel: Ext2 fix signed-unsigned comparisons --- kernel/kernel/FS/Ext2/Inode.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/kernel/FS/Ext2/Inode.cpp b/kernel/kernel/FS/Ext2/Inode.cpp index ac0baaad5f..03f9a0d9e0 100644 --- a/kernel/kernel/FS/Ext2/Inode.cpp +++ b/kernel/kernel/FS/Ext2/Inode.cpp @@ -108,10 +108,10 @@ namespace Kernel ASSERT(!mode().ifdir()); ASSERT(offset >= 0); - if (offset >= UINT32_MAX || buffer.size() >= UINT32_MAX || buffer.size() >= (size_t)(UINT32_MAX - offset)) + if (static_cast>(offset) >= UINT32_MAX || buffer.size() >= UINT32_MAX || buffer.size() >= (size_t)(UINT32_MAX - offset)) return BAN::Error::from_errno(EOVERFLOW); - if (offset >= m_inode.size) + if (static_cast>(offset) >= m_inode.size) return 0; uint32_t count = buffer.size(); @@ -152,7 +152,7 @@ namespace Kernel ASSERT(!mode().ifdir()); ASSERT(offset >= 0); - if (offset >= UINT32_MAX || buffer.size() >= UINT32_MAX || buffer.size() >= (size_t)(UINT32_MAX - offset)) + if (static_cast>(offset) >= UINT32_MAX || buffer.size() >= UINT32_MAX || buffer.size() >= (size_t)(UINT32_MAX - offset)) return BAN::Error::from_errno(EOVERFLOW); if (m_inode.size < offset + buffer.size()) @@ -304,7 +304,7 @@ done: ASSERT(mode().ifdir()); ASSERT(offset >= 0); - if (offset >= max_used_data_block_count()) + if (static_cast>(offset) >= max_used_data_block_count()) { list->entry_count = 0; return {};