mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:48:12 +00:00
FileSystem: fix errno on lseek() beyond the bounds of a file
These are all EINVAL. Also remove bogus assert on metadata.size.
This commit is contained in:
parent
abb7455163
commit
f1f3cd58b0
1 changed files with 3 additions and 3 deletions
|
@ -142,17 +142,17 @@ off_t FileDescriptor::seek(off_t offset, int whence)
|
||||||
break;
|
break;
|
||||||
case SEEK_CUR:
|
case SEEK_CUR:
|
||||||
newOffset = m_current_offset + offset;
|
newOffset = m_current_offset + offset;
|
||||||
if (newOffset < 0)
|
|
||||||
return -EINVAL;
|
|
||||||
break;
|
break;
|
||||||
case SEEK_END:
|
case SEEK_END:
|
||||||
ASSERT(metadata.size); // FIXME: What do I do?
|
|
||||||
newOffset = metadata.size;
|
newOffset = metadata.size;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newOffset < 0 || newOffset > metadata.size)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
m_current_offset = newOffset;
|
m_current_offset = newOffset;
|
||||||
return m_current_offset;
|
return m_current_offset;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue