Merge pull request #1623 from G10h4ck/fix_crash_in_p3banlist

Protect p3BanList::isAddressAccepted with mutex
This commit is contained in:
G10h4ck 2019-08-28 23:39:08 +02:00 committed by GitHub
commit 9f95649bbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -306,18 +306,23 @@ bool p3BanList::acceptedBanRanges_locked(const BanListPeer& blp)
}
return false ;
}
bool p3BanList::isAddressAccepted(
const sockaddr_storage& dAddr, uint32_t checking_flags,
uint32_t& check_result )
{
check_result = RSBANLIST_CHECK_RESULT_NOCHECK;
if(!mIPFilteringEnabled) return true;
sockaddr_storage addr; sockaddr_storage_copy(dAddr, addr);
if(!sockaddr_storage_ipv6_to_ipv4(addr)) return true;
if(sockaddr_storage_isLoopbackNet(addr)) return true;
RS_STACK_MUTEX(mBanMtx);
if(!mIPFilteringEnabled) return true;
#ifdef DEBUG_BANLIST
std::cerr << "isAddressAccepted(): tested addr=" << sockaddr_storage_iptostring(addr) << ", checking flags=" << checking_flags ;
#endif
@ -409,6 +414,7 @@ bool p3BanList::isAddressAccepted(
check_result = RSBANLIST_CHECK_RESULT_ACCEPTED;
return true ;
}
void p3BanList::getWhiteListedIps(std::list<BanListPeer> &lst)
{
RS_STACK_MUTEX(mBanMtx) ;
@ -582,11 +588,6 @@ int p3BanList::tick()
return 0;
}
int p3BanList::status()
{
return 1;
}
void p3BanList::getDhtInfo()
{
// Get the list of masquerading peers from the DHT. Add them as potential IPs to be banned.

View File

@ -105,7 +105,6 @@ public:
*/
virtual int tick();
virtual int status();
int sendPackets();
bool processIncoming();