Explorar el Código

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

Jelle Raaijmakers hace 4 años
padre
commit
3dab9d0b5c
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  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:
     case SEEK_END:
         if (!metadata().is_valid())
         if (!metadata().is_valid())
             return EIO;
             return EIO;
-        new_offset = metadata().size;
+        if (Checked<off_t>::addition_would_overflow(metadata().size, offset))
+            return EOVERFLOW;
+        new_offset = metadata().size + offset;
         break;
         break;
     default:
     default:
         return EINVAL;
         return EINVAL;