soc_u: Perform size checking for static buffers
Previously, the buffers pushed were too long and would trigger an ASSERT in our IPC handling code.
This commit is contained in:
parent
22c4eb86d7
commit
fea38f824d
@ -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<socklen_t>(rp.Pop<u32>());
|
||||
const auto max_addr_len = rp.Pop<u32>();
|
||||
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<u32>();
|
||||
const auto max_addr_len = rp.Pop<u32>();
|
||||
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<u32>();
|
||||
const auto max_addr_len = rp.Pop<u32>();
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user