瀏覽代碼

Ext2FS: Assert that inline symlink read/write always uses offset=0

Andreas Kling 5 年之前
父節點
當前提交
e91f03cb39
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      Kernel/FileSystem/Ext2FileSystem.cpp

+ 2 - 0
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<off_t>(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);