ramfs: fix off-by-one error

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-05 14:48:36 +02:00
commit ab15b88cd6

View file

@ -98,8 +98,8 @@ static ssize_t read(inode_t *inode, char *buf, size_t size, size_t offset)
if (offset >= inode->file_size)
return -EINVAL;
if (size + offset >= inode->file_size)
size = inode->file_size - offset - 1;
if (size + offset > inode->file_size)
size = inode->file_size - offset;
memcpy(buf, inode->data + offset, size);
ret = size;