fix(Core/IPLocation): Prevent crash when parsing invalid IP (#25095)
This commit is contained in:
@@ -107,17 +107,24 @@ void IpLocationStore::Load()
|
|||||||
|
|
||||||
IpLocationRecord const* IpLocationStore::GetLocationRecord(std::string const& ipAddress) const
|
IpLocationRecord const* IpLocationStore::GetLocationRecord(std::string const& ipAddress) const
|
||||||
{
|
{
|
||||||
uint32 ip = Acore::Net::address_to_uint(Acore::Net::make_address_v4(ipAddress));
|
uint32 ip;
|
||||||
auto itr = std::upper_bound(_ipLocationStore.begin(), _ipLocationStore.end(), ip, [](uint32 ip, IpLocationRecord const& loc) { return ip < loc.IpTo; });
|
|
||||||
if (itr == _ipLocationStore.end())
|
try
|
||||||
|
{
|
||||||
|
ip = Acore::Net::address_to_uint(Acore::Net::make_address_v4(ipAddress));
|
||||||
|
}
|
||||||
|
catch (boost::system::system_error const&)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ip < itr->IpFrom)
|
auto itr = std::upper_bound(_ipLocationStore.begin(), _ipLocationStore.end(), ip, [](uint32 ip, IpLocationRecord const& loc) { return ip < loc.IpTo; });
|
||||||
{
|
|
||||||
|
if (itr == _ipLocationStore.end())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if (ip < itr->IpFrom)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
return &(*itr);
|
return &(*itr);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user