From aedcd1bcc031448eb56a138d6e767bd9780196ef Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 7 Jan 2021 14:51:23 -0500 Subject: [PATCH] remove tag after tagset expiration --- libi2pd/ECIESX25519AEADRatchetSession.cpp | 2 +- libi2pd/Garlic.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libi2pd/ECIESX25519AEADRatchetSession.cpp b/libi2pd/ECIESX25519AEADRatchetSession.cpp index 870995e8..b8c47b73 100644 --- a/libi2pd/ECIESX25519AEADRatchetSession.cpp +++ b/libi2pd/ECIESX25519AEADRatchetSession.cpp @@ -107,7 +107,7 @@ namespace garlic bool ReceiveRatchetTagSet::IsIndexExpired (int index) const { - return index < m_TrimBehindIndex || !m_Session || m_Session->IsTerminated (); + return index < m_TrimBehindIndex; } bool ReceiveRatchetTagSet::HandleNextMessage (uint8_t * buf, size_t len, int index) diff --git a/libi2pd/Garlic.cpp b/libi2pd/Garlic.cpp index a2b012db..42aca5be 100644 --- a/libi2pd/Garlic.cpp +++ b/libi2pd/Garlic.cpp @@ -876,7 +876,12 @@ namespace garlic numExpiredTags++; } else + { + auto session = it->second.tagset->GetSession (); + if (!session || session->IsTerminated()) + it->second.tagset->Expire (); ++it; + } } if (numExpiredTags > 0) LogPrint (eLogDebug, "Garlic: ", numExpiredTags, " ECIESx25519 tags expired for ", GetIdentHash().ToBase64 ()); @@ -1101,7 +1106,7 @@ namespace garlic auto it = m_ECIESx25519Sessions.find (staticKey); if (it != m_ECIESx25519Sessions.end ()) { - it->second->SetOwner (nullptr); + it->second->Terminate (); m_ECIESx25519Sessions.erase (it); } }