1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 19:45:08 +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:
Robin Burchell 2019-05-16 15:44:01 +02:00 committed by Andreas Kling
parent abb7455163
commit f1f3cd58b0

View file

@ -142,17 +142,17 @@ off_t FileDescriptor::seek(off_t offset, int whence)
break;
case SEEK_CUR:
newOffset = m_current_offset + offset;
if (newOffset < 0)
return -EINVAL;
break;
case SEEK_END:
ASSERT(metadata.size); // FIXME: What do I do?
newOffset = metadata.size;
break;
default:
return -EINVAL;
}
if (newOffset < 0 || newOffset > metadata.size)
return -EINVAL;
m_current_offset = newOffset;
return m_current_offset;
}