mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-04 23:35:12 +01:00
Cleanup IStorageAccessor validation code
This commit is contained in:
parent
39faa739b9
commit
d3dc0bddc4
@ -14,11 +14,12 @@ namespace skyline::service::am {
|
||||
|
||||
Result IStorageAccessor::Write(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||
auto offset{request.Pop<i64>()};
|
||||
auto size{std::min(static_cast<i64>(request.inputBuf.at(0).size()), static_cast<i64>(parent->content.size()) - offset)};
|
||||
|
||||
if (offset > parent->content.size())
|
||||
if (offset < 0 || offset > parent->content.size())
|
||||
return result::OutOfBounds;
|
||||
|
||||
auto size{std::min(static_cast<i64>(request.inputBuf.at(0).size()), static_cast<i64>(parent->content.size()) - offset)};
|
||||
|
||||
if (size)
|
||||
span(parent->content).copy_from(request.inputBuf.at(0), size);
|
||||
|
||||
@ -27,12 +28,13 @@ namespace skyline::service::am {
|
||||
|
||||
Result IStorageAccessor::Read(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||
auto offset{request.Pop<i64>()};
|
||||
auto size{std::min(static_cast<i64>(request.outputBuf.at(0).size()), static_cast<i64>(parent->content.size()) - offset)};
|
||||
|
||||
if (offset > parent->content.size())
|
||||
if (offset < 0 || offset > parent->content.size())
|
||||
return result::OutOfBounds;
|
||||
|
||||
if (size > 0)
|
||||
auto size{std::min(static_cast<i64>(request.outputBuf.at(0).size()), static_cast<i64>(parent->content.size()) - offset)};
|
||||
|
||||
if (size)
|
||||
request.outputBuf.at(0).copy_from(span(parent->content.data() + offset, size));
|
||||
|
||||
return {};
|
||||
|
Loading…
Reference in New Issue
Block a user