diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp index 60e5f92ea6..05e2bc194e 100644 --- a/src/core/hle/service/soc_u.cpp +++ b/src/core/hle/service/soc_u.cpp @@ -868,7 +868,7 @@ void SOC_U::Accept(Kernel::HLERequestContext& ctx) { rb.Push(ERR_INVALID_HANDLE); return; } - [[maybe_unused]] const auto max_addr_len = static_cast(rp.Pop()); + const auto max_addr_len = rp.Pop(); rp.PopPID(); sockaddr addr; socklen_t addr_len = sizeof(addr); @@ -889,6 +889,11 @@ void SOC_U::Accept(Kernel::HLERequestContext& ctx) { std::memcpy(ctr_addr_buf.data(), &ctr_addr, sizeof(ctr_addr)); } + if (ctr_addr_buf.size() > max_addr_len) { + LOG_WARNING(Frontend, "CTRSockAddr is too long, truncating data."); + ctr_addr_buf.resize(max_addr_len); + } + IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); rb.Push(ret); @@ -1264,7 +1269,7 @@ void SOC_U::GetSockName(Kernel::HLERequestContext& ctx) { rb.Push(ERR_INVALID_HANDLE); return; } - [[maybe_unused]] const auto max_addr_len = rp.Pop(); + const auto max_addr_len = rp.Pop(); rp.PopPID(); sockaddr dest_addr; @@ -1278,6 +1283,11 @@ void SOC_U::GetSockName(Kernel::HLERequestContext& ctx) { if (ret != 0) ret = TranslateError(GET_ERRNO); + if (dest_addr_buff.size() > max_addr_len) { + LOG_WARNING(Frontend, "CTRSockAddr is too long, truncating data."); + dest_addr_buff.resize(max_addr_len); + } + IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); rb.Push(ret); @@ -1358,7 +1368,7 @@ void SOC_U::GetPeerName(Kernel::HLERequestContext& ctx) { rb.Push(ERR_INVALID_HANDLE); return; } - [[maybe_unused]] const auto max_addr_len = rp.Pop(); + const auto max_addr_len = rp.Pop(); rp.PopPID(); sockaddr dest_addr; @@ -1374,6 +1384,11 @@ void SOC_U::GetPeerName(Kernel::HLERequestContext& ctx) { result = TranslateError(GET_ERRNO); } + if (dest_addr_buff.size() > max_addr_len) { + LOG_WARNING(Frontend, "CTRSockAddr is too long, truncating data."); + dest_addr_buff.resize(max_addr_len); + } + IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); rb.Push(result);