mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-24 15:05:35 -04:00
fixed leak in gossipDiscovery
This commit is contained in:
parent
4a15c59356
commit
68d7edd405
1 changed files with 5 additions and 16 deletions
|
@ -258,8 +258,7 @@ int p3discovery2::handleIncoming()
|
||||||
|
|
||||||
++nhandled;
|
++nhandled;
|
||||||
|
|
||||||
Dbg4() << __PRETTY_FUNCTION__ << " Received item: " << std::endl
|
Dbg4() << __PRETTY_FUNCTION__ << " Received item: " << *item << std::endl;
|
||||||
<< *item << std::endl;
|
|
||||||
|
|
||||||
if((contact = dynamic_cast<RsDiscContactItem *>(item)) != nullptr)
|
if((contact = dynamic_cast<RsDiscContactItem *>(item)) != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -269,29 +268,25 @@ int p3discovery2::handleIncoming()
|
||||||
processContactInfo(item->PeerId(), contact);
|
processContactInfo(item->PeerId(), contact);
|
||||||
}
|
}
|
||||||
else if( (gxsidlst = dynamic_cast<RsDiscIdentityListItem *>(item)) != nullptr )
|
else if( (gxsidlst = dynamic_cast<RsDiscIdentityListItem *>(item)) != nullptr )
|
||||||
{
|
|
||||||
recvIdentityList(item->PeerId(),gxsidlst->ownIdentityList);
|
recvIdentityList(item->PeerId(),gxsidlst->ownIdentityList);
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
else if((pgpkey = dynamic_cast<RsDiscPgpKeyItem *>(item)) != nullptr)
|
else if((pgpkey = dynamic_cast<RsDiscPgpKeyItem *>(item)) != nullptr)
|
||||||
recvPGPCertificate(item->PeerId(), pgpkey);
|
recvPGPCertificate(item->PeerId(), pgpkey);
|
||||||
else if((pgpcert = dynamic_cast<RsDiscPgpCertItem *>(item)) != nullptr)
|
else if((pgpcert = dynamic_cast<RsDiscPgpCertItem *>(item)) != nullptr)
|
||||||
// sink
|
RsWarn() << "Received a deprecated RsDiscPgpCertItem. Will not be handled." << std::endl; // nothing to do.
|
||||||
delete pgpcert;
|
|
||||||
else if((pgplist = dynamic_cast<RsDiscPgpListItem *>(item)) != nullptr)
|
else if((pgplist = dynamic_cast<RsDiscPgpListItem *>(item)) != nullptr)
|
||||||
{
|
{
|
||||||
if (pgplist->mode == RsGossipDiscoveryPgpListMode::FRIENDS)
|
if (pgplist->mode == RsGossipDiscoveryPgpListMode::FRIENDS)
|
||||||
processPGPList(pgplist->PeerId(), pgplist);
|
processPGPList(pgplist->PeerId(), pgplist);
|
||||||
else if (pgplist->mode == RsGossipDiscoveryPgpListMode::GETCERT)
|
else if (pgplist->mode == RsGossipDiscoveryPgpListMode::GETCERT)
|
||||||
recvPGPCertificateRequest(pgplist->PeerId(), pgplist);
|
recvPGPCertificateRequest(pgplist->PeerId(), pgplist);
|
||||||
else delete item;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RsWarn() << __PRETTY_FUNCTION__ << " Received unknown item type " << (int)item->PacketSubType() << "! " << std::endl ;
|
RsWarn() << __PRETTY_FUNCTION__ << " Received unknown item type " << (int)item->PacketSubType() << "! " << std::endl ;
|
||||||
RsWarn() << item << std::endl;
|
RsWarn() << item << std::endl;
|
||||||
delete item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete item;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nhandled;
|
return nhandled;
|
||||||
|
@ -716,9 +711,6 @@ void p3discovery2::processPGPList(const RsPeerId &fromId, const RsDiscPgpListIte
|
||||||
|
|
||||||
it->second.mergeFriendList(item->pgpIdSet.ids);
|
it->second.mergeFriendList(item->pgpIdSet.ids);
|
||||||
updatePeers_locked(fromId);
|
updatePeers_locked(fromId);
|
||||||
|
|
||||||
// cleanup.
|
|
||||||
delete item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1041,8 +1033,6 @@ void p3discovery2::recvPGPCertificateRequest( const RsPeerId& fromId, const RsDi
|
||||||
sendPGPCertificate(pgpId, fromId);
|
sendPGPCertificate(pgpId, fromId);
|
||||||
else
|
else
|
||||||
std::cerr << "(WW) not sending certificate " << pgpId << " asked by friend " << fromId << " because this either this cert is not a friend, or discovery is off" << std::endl;
|
std::cerr << "(WW) not sending certificate " << pgpId << " asked by friend " << fromId << " because this either this cert is not a friend, or discovery is off" << std::endl;
|
||||||
|
|
||||||
delete item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1119,7 +1109,6 @@ void p3discovery2::recvPGPCertificate(const RsPeerId& fromId, RsDiscPgpKeyItem*
|
||||||
#endif
|
#endif
|
||||||
// now that will add the key *and* set the skip_signature_validation flag at once
|
// now that will add the key *and* set the skip_signature_validation flag at once
|
||||||
rsPeers->loadPgpKeyFromBinaryData((unsigned char*)item->bin_data,item->bin_len, tmp_pgp_id,error_string); // no error should occur at this point because we called loadDetailsFromStringCert() already
|
rsPeers->loadPgpKeyFromBinaryData((unsigned char*)item->bin_data,item->bin_len, tmp_pgp_id,error_string); // no error should occur at this point because we called loadDetailsFromStringCert() already
|
||||||
delete item;
|
|
||||||
|
|
||||||
// Make sure we allow connections after the key is added. This is not the case otherwise. We only do that if the peer is non validated peer, since
|
// Make sure we allow connections after the key is added. This is not the case otherwise. We only do that if the peer is non validated peer, since
|
||||||
// otherwise the connection should already be accepted. This only happens when the short invite peer sends its own PGP key.
|
// otherwise the connection should already be accepted. This only happens when the short invite peer sends its own PGP key.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue