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.
This commit is contained in:
Andreas Kling 2019-04-27 17:14:27 +02:00
parent 100cb2a237
commit dde8d90747
Notes: sideshowbarker 2024-07-19 14:34:26 +09:00

View file

@ -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);