diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp index e80cf76275c..30a3e5d81ff 100644 --- a/Kernel/FileSystem/FileDescription.cpp +++ b/Kernel/FileSystem/FileDescription.cpp @@ -136,7 +136,9 @@ KResultOr FileDescription::seek(off_t offset, int whence) case SEEK_END: if (!metadata().is_valid()) return EIO; - new_offset = metadata().size; + if (Checked::addition_would_overflow(metadata().size, offset)) + return EOVERFLOW; + new_offset = metadata().size + offset; break; default: return EINVAL;