From e91f03cb3992bd0f93f88522767c59e6a83fd709 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 15 Jan 2020 22:04:57 +0100 Subject: [PATCH] Ext2FS: Assert that inline symlink read/write always uses offset=0 --- Kernel/FileSystem/Ext2FileSystem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index a3f5ae00d5..aedb5ecb8f 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -611,6 +611,7 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, u8* buffer, FileDes // Symbolic links shorter than 60 characters are store inline inside the i_block array. // This avoids wasting an entire block on short links. (Most links are short.) if (is_symlink() && size() < max_inline_symlink_length) { + ASSERT(offset == 0); ssize_t nread = min((off_t)size() - offset, static_cast(count)); memcpy(buffer, ((const u8*)m_raw_inode.i_block) + offset, (size_t)nread); return nread; @@ -722,6 +723,7 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const u8* data, Fi Locker fs_locker(fs().m_lock); if (is_symlink()) { + ASSERT(offset == 0); if (max((size_t)(offset + count), (size_t)m_raw_inode.i_size) < max_inline_symlink_length) { #ifdef EXT2_DEBUG dbgprintf("Ext2FSInode: write_bytes poking into i_block array for inline symlink '%s' (%u bytes)\n", String((const char*)data, count).characters(), count);