From a712d4ac0cf711ec3f8bcad48f504dc224f26215 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 17 Nov 2019 19:12:29 +0100 Subject: [PATCH] Ext2FS: Writing to a slow symlink should not treat it like a fast one We would misinterpret short writes to the first 60 bytes of a slow symlink as writes to a fast symlink. --- Kernel/FileSystem/Ext2FileSystem.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 9ec3b29139..8e0446ef9e 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -722,13 +722,12 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const u8* data, Fi Locker fs_locker(fs().m_lock); if (is_symlink()) { - // FIXME: This doesn't seem right if the inode is already bigger than 'max_inline_symlink_length' - if ((offset + count) < max_inline_symlink_length) { + 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); #endif memcpy(((u8*)m_raw_inode.i_block) + offset, data, (size_t)count); - if ((offset + count) > (off_t)m_raw_inode.i_size) + if ((size_t)(offset + count) > (size_t)m_raw_inode.i_size) m_raw_inode.i_size = offset + count; set_metadata_dirty(true); return count;