[XAM/Settings] Check if provided size doesn't exceed maximal setting size

This commit is contained in:
Gliniak 2022-08-21 17:46:00 +02:00
parent 0b013fdc6b
commit da00ede181
1 changed files with 10 additions and 0 deletions

View File

@ -385,9 +385,19 @@ dword_result_t XamUserWriteProfileSettings_entry(
switch (setting_type) {
case UserProfile::Setting::Type::CONTENT:
case UserProfile::Setting::Type::BINARY: {
UserProfile::Setting::Key setting_key;
setting_key.value = static_cast<uint32_t>(setting.setting_id);
uint8_t* binary_ptr =
kernel_state()->memory()->TranslateVirtual(setting.data.binary.ptr);
size_t binary_size = setting.data.binary.size;
if (setting_key.size < binary_size) {
XELOGW(
"XamUserWriteProfileSettings: binary size > key size. Shrinking "
"binary size!");
binary_size = setting_key.size;
}
std::vector<uint8_t> bytes;
if (setting.data.binary.ptr) {
// Copy provided data