From d90cc3a7e99ee8f6a2de1046c489c636d844ab21 Mon Sep 17 00:00:00 2001 From: Cancerous Date: Sun, 22 Dec 2019 21:29:19 -0500 Subject: [PATCH] [Kernel] added more checks to filter user_index out of range --- src/xenia/hid/input_system.cc | 16 ++++++++++++++++ src/xenia/kernel/xam/xam_user.cc | 12 ++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/xenia/hid/input_system.cc b/src/xenia/hid/input_system.cc index a77d5b548..2cfcb9781 100644 --- a/src/xenia/hid/input_system.cc +++ b/src/xenia/hid/input_system.cc @@ -30,6 +30,10 @@ X_RESULT InputSystem::GetCapabilities(uint32_t user_index, uint32_t flags, X_INPUT_CAPABILITIES* out_caps) { SCOPE_profile_cpu_f("hid"); + if (user_index && user_index != 0xFF) { + return X_ERROR_NO_SUCH_USER; + } + bool any_connected = false; for (auto& driver : drivers_) { X_RESULT result = driver->GetCapabilities(user_index, flags, out_caps); @@ -45,6 +49,10 @@ X_RESULT InputSystem::GetCapabilities(uint32_t user_index, uint32_t flags, X_RESULT InputSystem::GetState(uint32_t user_index, X_INPUT_STATE* out_state) { SCOPE_profile_cpu_f("hid"); + + if (user_index && user_index != 0xFF) { + return X_ERROR_NO_SUCH_USER; + } bool any_connected = false; for (auto& driver : drivers_) { @@ -62,6 +70,10 @@ X_RESULT InputSystem::GetState(uint32_t user_index, X_INPUT_STATE* out_state) { X_RESULT InputSystem::SetState(uint32_t user_index, X_INPUT_VIBRATION* vibration) { SCOPE_profile_cpu_f("hid"); + + if (user_index && user_index != 0xFF) { + return X_ERROR_NO_SUCH_USER; + } bool any_connected = false; for (auto& driver : drivers_) { @@ -79,6 +91,10 @@ X_RESULT InputSystem::SetState(uint32_t user_index, X_RESULT InputSystem::GetKeystroke(uint32_t user_index, uint32_t flags, X_INPUT_KEYSTROKE* out_keystroke) { SCOPE_profile_cpu_f("hid"); + + if (user_index && user_index != 0xFF) { + return X_ERROR_NO_SUCH_USER; + } bool any_connected = false; for (auto& driver : drivers_) { diff --git a/src/xenia/kernel/xam/xam_user.cc b/src/xenia/kernel/xam/xam_user.cc index eed44de97..4f21538e3 100644 --- a/src/xenia/kernel/xam/xam_user.cc +++ b/src/xenia/kernel/xam/xam_user.cc @@ -105,7 +105,7 @@ DECLARE_XAM_EXPORT1(XamProfileEnumerate, kUserProfiles, kImplemented); X_HRESULT_result_t XamUserGetXUID(dword_t user_index, dword_t unk, lpqword_t xuid_ptr) { - if (user_index) { + if (user_index && user_index != 0xFF) { return X_E_NO_SUCH_USER; } const auto& user_profile = kernel_state()->user_profile(); @@ -150,11 +150,12 @@ X_HRESULT_result_t XamUserGetSigninInfo(dword_t user_index, dword_t flags, return X_E_INVALIDARG; } - std::memset(info, 0, sizeof(X_USER_SIGNIN_INFO)); - if (user_index) { + if (user_index && user_index != 0xFF) { return X_E_NO_SUCH_USER; } + std::memset(info, 0, sizeof(X_USER_SIGNIN_INFO)); + const auto& user_profile = kernel_state()->user_profile(); info->xuid = user_profile->xuid(); info->signin_state = ((cvars::signin_state) ? 1 : 0); @@ -165,7 +166,10 @@ DECLARE_XAM_EXPORT1(XamUserGetSigninInfo, kUserProfiles, kImplemented); dword_result_t XamUserGetName(dword_t user_index, lpstring_t buffer, dword_t buffer_len) { - if (user_index) { + + XELOGI("XamUserGetName user_index:(%d) buffer_length:(%d)", user_index, buffer_len); + + if (user_index && user_index != 0xFF) { return X_ERROR_NO_SUCH_USER; }