From dde8d90747712d7bca65bf1471143a35bf71040d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 27 Apr 2019 17:14:27 +0200 Subject: [PATCH] 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. --- Kernel/FileSystem/Ext2FileSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index f8d161472c..94bf18226a 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/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);