mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-04 19:14:01 +00:00
BTReal: Handle case where a link key may be invalid within LoadLinkKeys()
This can only occur if a user purposely corrupts their config file, but still, we may as well protect users from themselves.
This commit is contained in:
parent
ce69201f33
commit
59846378b3
@ -514,8 +514,17 @@ void BluetoothReal::LoadLinkKeys()
|
|||||||
if (index == std::string::npos)
|
if (index == std::string::npos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bdaddr_t address = Common::StringToMacAddress(pair.substr(0, index)).value();
|
const std::string address_string = pair.substr(0, index);
|
||||||
std::reverse(address.begin(), address.end());
|
std::optional<bdaddr_t> address = Common::StringToMacAddress(address_string);
|
||||||
|
if (!address)
|
||||||
|
{
|
||||||
|
ERROR_LOG(IOS_WIIMOTE, "Malformed MAC address (%s). Skipping loading of current link key.",
|
||||||
|
address_string.c_str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& mac = address.value();
|
||||||
|
std::reverse(mac.begin(), mac.end());
|
||||||
|
|
||||||
const std::string& key_string = pair.substr(index + 1);
|
const std::string& key_string = pair.substr(index + 1);
|
||||||
linkkey_t key{};
|
linkkey_t key{};
|
||||||
@ -527,7 +536,7 @@ void BluetoothReal::LoadLinkKeys()
|
|||||||
key[pos++] = value;
|
key[pos++] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_link_keys[address] = key;
|
m_link_keys[mac] = key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user