From 8f4fa8a5b6ccdb9427ef12c8228fd80841fcf591 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 8 Apr 2018 22:34:37 +0200 Subject: [PATCH] cellPad: check for more invalid parameters --- rpcs3/Emu/Cell/Modules/cellPad.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellPad.cpp b/rpcs3/Emu/Cell/Modules/cellPad.cpp index 592ce0fc2f..901fab8e5e 100644 --- a/rpcs3/Emu/Cell/Modules/cellPad.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPad.cpp @@ -81,7 +81,7 @@ s32 cellPadGetData(u32 port_no, vm::ptr data) const PadInfo& rinfo = handler->GetInfo(); - if (port_no >= rinfo.max_connect) + if (port_no >= rinfo.max_connect || !data) return CELL_PAD_ERROR_INVALID_PARAMETER; const auto& pads = handler->GetPads(); @@ -319,6 +319,9 @@ s32 cellPadPeriphGetInfo(vm::ptr info) if (!handler) return CELL_PAD_ERROR_UNINITIALIZED; + if (!info) + return CELL_PAD_ERROR_INVALID_PARAMETER; + const PadInfo& rinfo = handler->GetInfo(); std::memset(info.get_ptr(), 0, sizeof(CellPadPeriphInfo)); @@ -357,7 +360,7 @@ s32 cellPadPeriphGetData(u32 port_no, vm::ptr data) const PadInfo& rinfo = handler->GetInfo(); - if (port_no >= rinfo.max_connect) + if (port_no >= rinfo.max_connect || !data) return CELL_PAD_ERROR_INVALID_PARAMETER; const auto& pads = handler->GetPads(); @@ -388,7 +391,7 @@ s32 cellPadGetDataExtra(u32 port_no, vm::ptr device_type, vm::ptrGetInfo(); - if (port_no >= rinfo.max_connect) + if (port_no >= rinfo.max_connect || !device_type || !data) return CELL_PAD_ERROR_INVALID_PARAMETER; const auto& pads = handler->GetPads(); @@ -420,7 +423,7 @@ s32 cellPadSetActDirect(u32 port_no, vm::ptr param) const PadInfo& rinfo = handler->GetInfo(); - if (port_no >= rinfo.max_connect) + if (port_no >= rinfo.max_connect || !param) return CELL_PAD_ERROR_INVALID_PARAMETER; const auto& pads = handler->GetPads(); @@ -443,6 +446,9 @@ s32 cellPadGetInfo(vm::ptr info) if (!handler) return CELL_PAD_ERROR_UNINITIALIZED; + if (!info) + return CELL_PAD_ERROR_INVALID_PARAMETER; + std::memset(info.get_ptr(), 0, sizeof(CellPadInfo)); const PadInfo& rinfo = handler->GetInfo(); @@ -475,6 +481,9 @@ s32 cellPadGetInfo2(vm::ptr info) if (!handler) return CELL_PAD_ERROR_UNINITIALIZED; + if (!info) + return CELL_PAD_ERROR_INVALID_PARAMETER; + std::memset(info.get_ptr(), 0, sizeof(CellPadInfo2)); const PadInfo& rinfo = handler->GetInfo(); @@ -510,7 +519,7 @@ s32 cellPadGetCapabilityInfo(u32 port_no, vm::ptr info) const PadInfo& rinfo = handler->GetInfo(); - if (port_no >= rinfo.max_connect) + if (port_no >= rinfo.max_connect || !info) return CELL_PAD_ERROR_INVALID_PARAMETER; const auto& pads = handler->GetPads(); @@ -679,6 +688,9 @@ s32 cellPadLddDataInsert(s32 handle, vm::ptr data) if (!handler) return CELL_PAD_ERROR_UNINITIALIZED; + if (handle < 0 || !data) + return CELL_PAD_ERROR_INVALID_PARAMETER; + return CELL_OK; } @@ -707,6 +719,9 @@ s32 cellPadLddUnregisterController(s32 handle) if (!handler) return CELL_PAD_ERROR_UNINITIALIZED; + if (handle < 0) + return CELL_PAD_ERROR_INVALID_PARAMETER; + return CELL_OK; }