From 15b749c2baaa2f4ea4cca6cc0b5e1cb31f8aec67 Mon Sep 17 00:00:00 2001 From: QDarkRex Date: Sun, 27 Sep 2026 12:38:59 +0700 Subject: [PATCH] fix(kernel): return 64-bit offsets from sceKernelLseek The SCE ABI returns off_t; offsets above INT_MAX threw instead of being returned. Co-Authored-By: Claude Opus 5.5 --- core/libs/prx/libkernel/File/include/File.hpp | 2 +- core/libs/prx/libkernel/File/src/Open.cpp | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/core/libs/prx/libkernel/File/include/File.hpp b/core/libs/prx/libkernel/File/include/File.hpp index 0037b90dd..cb3f099ff 100644 --- a/core/libs/prx/libkernel/File/include/File.hpp +++ b/core/libs/prx/libkernel/File/include/File.hpp @@ -13,7 +13,7 @@ int APS5_VABI sceKernelOpen(const char* path, int flags, std::uint16_t mode); int APS5_VABI sceKernelClose(int d); std::int64_t APS5_VABI sceKernelRead(int d, void* buf, std::size_t nbytes); std::int64_t APS5_VABI sceKernelWrite(int d, const void* buf, std::size_t nbytes); -int APS5_VABI sceKernelLseek(int d, std::int64_t offset, int whence); +std::int64_t APS5_VABI sceKernelLseek(int d, std::int64_t offset, int whence); int APS5_VABI sceKernelStat(const char* path, FileStat* sb); int APS5_VABI sceKernelUnlink(const char* path); diff --git a/core/libs/prx/libkernel/File/src/Open.cpp b/core/libs/prx/libkernel/File/src/Open.cpp index d1f3a9cbe..d22122583 100644 --- a/core/libs/prx/libkernel/File/src/Open.cpp +++ b/core/libs/prx/libkernel/File/src/Open.cpp @@ -132,7 +132,7 @@ std::int64_t APS5_VABI sceKernelWrite(int d, const void* buf, std::size_t nbytes return static_cast(n); } -int APS5_VABI sceKernelLseek(int d, std::int64_t offset, int whence) { +std::int64_t APS5_VABI sceKernelLseek(int d, std::int64_t offset, int whence) { if (whence < 0 || whence > 2) { throw std::invalid_argument(std::string(__func__) + ": invalid whence=" + std::to_string(whence)); } @@ -140,10 +140,7 @@ int APS5_VABI sceKernelLseek(int d, std::int64_t offset, int whence) { if (result < 0) { throw std::runtime_error(std::string(__func__) + ": lseek failed, fd=" + std::to_string(d) + ", errno=" + std::to_string(errno)); } - if (result > static_cast(std::numeric_limits::max())) { - throw std::overflow_error(std::string(__func__) + ": result " + std::to_string(result) + " overflows int return type"); - } - return static_cast(result); + return result; } int APS5_VABI sceKernelStat(const char* path, FileStat* sb) {