소스 검색

Kernel: Implement offset for `lseek` with `SEEK_END`

Jelle Raaijmakers 4 년 전
부모
커밋
3dab9d0b5c
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      Kernel/FileSystem/FileDescription.cpp

+ 3 - 1
Kernel/FileSystem/FileDescription.cpp

@@ -136,7 +136,9 @@ KResultOr<off_t> FileDescription::seek(off_t offset, int whence)
     case SEEK_END:
         if (!metadata().is_valid())
             return EIO;
-        new_offset = metadata().size;
+        if (Checked<off_t>::addition_would_overflow(metadata().size, offset))
+            return EOVERFLOW;
+        new_offset = metadata().size + offset;
         break;
     default:
         return EINVAL;