mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
Ext2FS: Assert that inline symlink read/write always uses offset=0
This commit is contained in:
parent
5a13a5416e
commit
e91f03cb39
Notes:
sideshowbarker
2024-07-19 10:02:29 +09:00
Author: https://github.com/awesomekling
Commit: e91f03cb39
1 changed files with 2 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue