mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-02 04:27:12 +02:00
Kernel: Resize Ext2FSInode when writing directory contents (#6897)
Ext2 directory contents are stored in a linked list of ext2_dir_entry structs. There is no sentinel value to determine where the list ends. Instead the list fills the entirety of the allocated space for the inode. Previously the inode was not correctly resized when it became smaller. This resulted in stale data being interpreted as part of the linked list of directory entries.
This commit is contained in:
Notes:
sideshowbarker
2024-07-18 18:38:28 +09:00
Author: https://github.com/Maato Commit: https://github.com/SerenityOS/serenity/commit/6e641fadfa6 Pull-request: https://github.com/SerenityOS/serenity/pull/6897 Issue: https://github.com/SerenityOS/serenity/issues/6367
@@ -1112,6 +1112,9 @@ KResult Ext2FSInode::write_directory(const Vector<Ext2FSDirectoryEntry>& entries
|
||||
|
||||
stream.fill_to_end(0);
|
||||
|
||||
if (auto result = resize(stream.size()); result.is_error())
|
||||
return result;
|
||||
|
||||
auto buffer = UserOrKernelBuffer::for_kernel_buffer(stream.data());
|
||||
auto result = write_bytes(0, stream.size(), buffer, nullptr);
|
||||
if (result.is_error())
|
||||
|
||||
Reference in New Issue
Block a user