From 9dc46eee850faa13f1f82ad2214e9a6e3f9b1259 Mon Sep 17 00:00:00 2001 From: gibbed Date: Mon, 3 Dec 2018 12:00:56 -0600 Subject: [PATCH] [Kernel] Null terminate string in XamContentGetDeviceName. --- src/xenia/kernel/xam/xam_content.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/xenia/kernel/xam/xam_content.cc b/src/xenia/kernel/xam/xam_content.cc index 83edcd58f..d9c278cf1 100644 --- a/src/xenia/kernel/xam/xam_content.cc +++ b/src/xenia/kernel/xam/xam_content.cc @@ -57,11 +57,13 @@ dword_result_t XamContentGetDeviceName(dword_t device_id, return X_ERROR_DEVICE_NOT_CONNECTED; } - if (name_capacity < wcslen(dummy_device_info_.name) + 1) { + auto name = std::wstring(dummy_device_info_.name); + if (name_capacity < name.size() + 1) { return X_ERROR_INSUFFICIENT_BUFFER; } - xe::store_and_swap(name_buffer, dummy_device_info_.name); + xe::store_and_swap(name_buffer, name); + ((wchar_t*)name_buffer)[name.size()] = 0; return X_ERROR_SUCCESS; } DECLARE_XAM_EXPORT1(XamContentGetDeviceName, kContent, kImplemented);