mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
Avoid out of memory with cellGameGetParamString
This commit is contained in:
parent
9d9b5c4d66
commit
4488312e81
@ -837,10 +837,17 @@ error_code cellGameGetParamString(s32 id, vm::ptr<char> buf, u32 bufsize)
|
||||
return CELL_GAME_ERROR_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
std::string value = psf::get_string(prm->sfo, std::string(key.name));
|
||||
value.resize(bufsize - 1);
|
||||
const std::string value = psf::get_string(prm->sfo, std::string(key.name));
|
||||
const auto value_size = value.size() + 1;
|
||||
|
||||
std::memcpy(buf.get_ptr(), value.c_str(), bufsize);
|
||||
const auto pbuf = buf.get_ptr();
|
||||
const bool to_pad = bufsize > value_size;
|
||||
std::memcpy(pbuf, value.c_str(), to_pad ? value_size : bufsize);
|
||||
|
||||
if (to_pad)
|
||||
{
|
||||
std::memset(pbuf + value_size, 0, bufsize - value_size);
|
||||
}
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user