summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Morph2021-08-04 22:32:09 -0400
committerGravatar Morph2021-08-04 22:32:09 -0400
commitf10dc35dd0d23475b65e7c3830eb13f3cad45a89 (patch)
tree97bdcc3860510112b7bf6031545067fbfc4b52ac /src
parentnvdec: Implement VA-API hardware video acceleration (#6713) (diff)
downloadyuzu-f10dc35dd0d23475b65e7c3830eb13f3cad45a89.tar.gz
yuzu-f10dc35dd0d23475b65e7c3830eb13f3cad45a89.tar.xz
yuzu-f10dc35dd0d23475b65e7c3830eb13f3cad45a89.zip
applet_swkbd: Include the null terminator in the buffer size calculation
Some games may interpret the read string as a null-terminated string instead of just reading the string up to buffer_size.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/am/applets/applet_software_keyboard.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/hle/service/am/applets/applet_software_keyboard.cpp b/src/core/hle/service/am/applets/applet_software_keyboard.cpp
index 673abb755..c89aa1bbf 100644
--- a/src/core/hle/service/am/applets/applet_software_keyboard.cpp
+++ b/src/core/hle/service/am/applets/applet_software_keyboard.cpp
@@ -377,7 +377,8 @@ void SoftwareKeyboard::SubmitForTextCheck(std::u16string submitted_text) {
377 377
378 if (swkbd_config_common.use_utf8) { 378 if (swkbd_config_common.use_utf8) {
379 std::string utf8_submitted_text = Common::UTF16ToUTF8(current_text); 379 std::string utf8_submitted_text = Common::UTF16ToUTF8(current_text);
380 const u64 buffer_size = utf8_submitted_text.size(); 380 // Include the null terminator in the buffer size.
381 const u64 buffer_size = utf8_submitted_text.size() + 1;
381 382
382 LOG_DEBUG(Service_AM, "\nBuffer Size: {}\nUTF-8 Submitted Text: {}", buffer_size, 383 LOG_DEBUG(Service_AM, "\nBuffer Size: {}\nUTF-8 Submitted Text: {}", buffer_size,
383 utf8_submitted_text); 384 utf8_submitted_text);
@@ -386,7 +387,8 @@ void SoftwareKeyboard::SubmitForTextCheck(std::u16string submitted_text) {
386 std::memcpy(out_data.data() + sizeof(u64), utf8_submitted_text.data(), 387 std::memcpy(out_data.data() + sizeof(u64), utf8_submitted_text.data(),
387 utf8_submitted_text.size()); 388 utf8_submitted_text.size());
388 } else { 389 } else {
389 const u64 buffer_size = current_text.size() * sizeof(char16_t); 390 // Include the null terminator in the buffer size.
391 const u64 buffer_size = (current_text.size() + 1) * sizeof(char16_t);
390 392
391 LOG_DEBUG(Service_AM, "\nBuffer Size: {}\nUTF-16 Submitted Text: {}", buffer_size, 393 LOG_DEBUG(Service_AM, "\nBuffer Size: {}\nUTF-16 Submitted Text: {}", buffer_size,
392 Common::UTF16ToUTF8(current_text)); 394 Common::UTF16ToUTF8(current_text));