mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 12:05:08 +00:00
Kernel: read() and write() should EOVERFLOW if (offset+size) overflows
This commit is contained in:
parent
20b2bfcafd
commit
0c44a12247
2 changed files with 25 additions and 0 deletions
|
@ -105,6 +105,8 @@ off_t FileDescription::seek(off_t offset, int whence)
|
|||
ssize_t FileDescription::read(u8* buffer, ssize_t count)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
if ((m_current_offset + count) < 0)
|
||||
return -EOVERFLOW;
|
||||
SmapDisabler disabler;
|
||||
int nread = m_file->read(*this, buffer, count);
|
||||
if (nread > 0 && m_file->is_seekable())
|
||||
|
@ -115,6 +117,8 @@ ssize_t FileDescription::read(u8* buffer, ssize_t count)
|
|||
ssize_t FileDescription::write(const u8* data, ssize_t size)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
if ((m_current_offset + size) < 0)
|
||||
return -EOVERFLOW;
|
||||
SmapDisabler disabler;
|
||||
int nwritten = m_file->write(*this, data, size);
|
||||
if (nwritten > 0 && m_file->is_seekable())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue