mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Use unordered_multimap for ingoingQueue
This will avoid the possibility for a malicious node to cause a memory leak and smash items in incoming queue of others nodes
This commit is contained in:
parent
b9091c4ad8
commit
77c430d553
@ -568,19 +568,20 @@ void p3GxsMails::processOutgoingRecord(OutgoingRecord& pr)
|
|||||||
case GxsMailStatus::PENDING_RECEIPT_RECEIVE:
|
case GxsMailStatus::PENDING_RECEIPT_RECEIVE:
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(ingoingMutex);
|
RS_STACK_MUTEX(ingoingMutex);
|
||||||
auto it = ingoingQueue.find(pr.mailItem.mailId);
|
auto range = ingoingQueue.equal_range(pr.mailItem.mailId);
|
||||||
if (it == ingoingQueue.end()) break;
|
for( auto it = range.first; it != range.second; ++it)
|
||||||
|
{
|
||||||
RsGxsMailPresignedReceipt* rt =
|
RsGxsMailPresignedReceipt* rt =
|
||||||
dynamic_cast<RsGxsMailPresignedReceipt*>(it->second);
|
dynamic_cast<RsGxsMailPresignedReceipt*>(it->second);
|
||||||
if( !rt || !idService.isOwnId(rt->meta.mAuthorId) ) break;
|
if(rt && idService.isOwnId(rt->meta.mAuthorId))
|
||||||
|
{
|
||||||
ingoingQueue.erase(it); delete rt;
|
ingoingQueue.erase(it); delete rt;
|
||||||
pr.status = GxsMailStatus::RECEIPT_RECEIVED;
|
pr.status = GxsMailStatus::RECEIPT_RECEIVED;
|
||||||
// TODO: Malicious adversary could forge messages with same mailId and
|
break;
|
||||||
// could end up overriding the legit receipt in ingoingQueue, and
|
}
|
||||||
// causing also a memleak(using unordered_multimap for ingoingQueue
|
}
|
||||||
// may fix this?)
|
|
||||||
// TODO: Resend message if older then treshold
|
// TODO: Resend message if older then treshold
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case GxsMailStatus::RECEIPT_RECEIVED:
|
case GxsMailStatus::RECEIPT_RECEIVED:
|
||||||
break;
|
break;
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "retroshare/rsgxsifacetypes.h" // For RsGxsId, RsGxsCircleId
|
#include "retroshare/rsgxsifacetypes.h" // For RsGxsId, RsGxsCircleId
|
||||||
#include "gxs/gxstokenqueue.h" // For GxsTokenQueue
|
#include "gxs/gxstokenqueue.h" // For GxsTokenQueue
|
||||||
@ -184,7 +186,7 @@ private:
|
|||||||
RsMutex outgoingMutex;
|
RsMutex outgoingMutex;
|
||||||
void processOutgoingRecord(OutgoingRecord& r);
|
void processOutgoingRecord(OutgoingRecord& r);
|
||||||
|
|
||||||
typedef std::map<RsGxsMailId, RsGxsMailBaseItem*> inMap;
|
typedef std::unordered_multimap<RsGxsMailId, RsGxsMailBaseItem*> inMap;
|
||||||
inMap ingoingQueue;
|
inMap ingoingQueue;
|
||||||
RsMutex ingoingMutex;
|
RsMutex ingoingMutex;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user