Skip to content

Commit a712d4a

Browse files
committed
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.
1 parent 5d08665 commit a712d4a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Kernel/FileSystem/Ext2FileSystem.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,13 +722,12 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const u8* data, Fi
722722
Locker fs_locker(fs().m_lock);
723723

724724
if (is_symlink()) {
725-
// FIXME: This doesn't seem right if the inode is already bigger than 'max_inline_symlink_length'
726-
if ((offset + count) < max_inline_symlink_length) {
725+
if (max((size_t)(offset + count), (size_t)m_raw_inode.i_size) < max_inline_symlink_length) {
727726
#ifdef EXT2_DEBUG
728727
dbgprintf("Ext2FSInode: write_bytes poking into i_block array for inline symlink '%s' (%u bytes)\n", String((const char*)data, count).characters(), count);
729728
#endif
730729
memcpy(((u8*)m_raw_inode.i_block) + offset, data, (size_t)count);
731-
if ((offset + count) > (off_t)m_raw_inode.i_size)
730+
if ((size_t)(offset + count) > (size_t)m_raw_inode.i_size)
732731
m_raw_inode.i_size = offset + count;
733732
set_metadata_dirty(true);
734733
return count;

0 commit comments

Comments
 (0)