瀏覽代碼

Ext2FS: Fix accidental zero-fill when appending to a file.

We were using the old file size, rather than the new file size, to determine
how much to zero-fill in the last block of a file.
Andreas Kling 6 年之前
父節點
當前提交
dde8d90747
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Kernel/FileSystem/Ext2FileSystem.cpp

+ 1 - 1
Kernel/FileSystem/Ext2FileSystem.cpp

@@ -558,7 +558,7 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const byte* data,
 
     int offset_into_first_block = offset % block_size;
 
-    int last_logical_block_index_in_file = size() / block_size;
+    int last_logical_block_index_in_file = new_size / block_size;
 
     ssize_t nwritten = 0;
     int remaining_count = min((off_t)count, (off_t)new_size - offset);