Skip to content

Commit

Permalink
FileSystem: fix errno on lseek() beyond the bounds of a file
Browse files Browse the repository at this point in the history
These are all EINVAL. Also remove bogus assert on metadata.size.
  • Loading branch information
rburchell authored and awesomekling committed May 16, 2019
1 parent abb7455 commit f1f3cd5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Kernel/FileSystem/FileDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f1f3cd5

Please sign in to comment.