diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-17 19:12:29 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-17 19:19:00 +0100 |
commit | a712d4ac0cf711ec3f8bcad48f504dc224f26215 (patch) | |
tree | 14d662c55cbeb7db79aedcdc56d2c803be05f182 /Kernel/FileSystem/Ext2FileSystem.cpp | |
parent | 5d08665d9a415e69cf8c2bca087ece7e43087ab1 (diff) | |
download | serenity-a712d4ac0cf711ec3f8bcad48f504dc224f26215.zip |
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.
Diffstat (limited to 'Kernel/FileSystem/Ext2FileSystem.cpp')
-rw-r--r-- | Kernel/FileSystem/Ext2FileSystem.cpp | 5 |
1 files 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; |