From 5d5cd717140c0a8ea5fbf56156f8908fb513e144 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 12 Apr 2019 11:13:46 -0400 Subject: [PATCH] limit expiration by next midnight for encrypted LS2 --- libi2pd/LeaseSet.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libi2pd/LeaseSet.cpp b/libi2pd/LeaseSet.cpp index e0258831..77751cbd 100644 --- a/libi2pd/LeaseSet.cpp +++ b/libi2pd/LeaseSet.cpp @@ -872,10 +872,11 @@ namespace data memcpy (m_Buffer + offset, blindedPub, 32); offset += 32; // Blinded Public Key auto timestamp = i2p::util::GetSecondsSinceEpoch (); htobe32buf (m_Buffer + offset, timestamp); offset += 4; // published timestamp (seconds) - auto expirationTime = ls->GetExpirationTime (); - SetExpirationTime (expirationTime); - auto expires = expirationTime/1000LL - timestamp; - htobe16buf (m_Buffer + offset, expires > 0 ? expires : 0); offset += 2; // expires + auto nextMidnight = (timestamp/86400LL + 1)*86400LL; // 86400 = 24*3600 seconds + auto expirationTime = ls->GetExpirationTime ()/1000LL; + if (expirationTime > nextMidnight) expirationTime = nextMidnight; + SetExpirationTime (expirationTime*1000LL); + htobe16buf (m_Buffer + offset, expirationTime > timestamp ? expirationTime - timestamp : 0); offset += 2; // expires uint16_t flags = 0; htobe16buf (m_Buffer + offset, flags); offset += 2; // flags htobe16buf (m_Buffer + offset, lenOuterCiphertext); offset += 2; // lenOuterCiphertext