* Add LeaseSetBufferValidate which checks lease validity and extracts timestamp

* check for leases with LeaseSetBufferValidate before update in floodfill code as to prevent malicous nodes removing good LS
This commit is contained in:
Jeff Becker 2018-01-24 10:16:51 -05:00
parent 3820b51960
commit 4a77a03033
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05
3 changed files with 46 additions and 8 deletions

View file

@ -237,22 +237,20 @@ namespace data
auto it = m_LeaseSets.find(ident);
if (it != m_LeaseSets.end ())
{
if (it->second->IsNewer (buf, len))
uint64_t expires;
if(LeaseSetBufferValidate(buf, len, expires))
{
it->second->Update (buf, len);
if (it->second->IsValid ())
if(it->second->GetExpirationTime() < expires)
{
it->second->Update (buf, len);
LogPrint (eLogInfo, "NetDb: LeaseSet updated: ", ident.ToBase32());
updated = true;
}
else
{
LogPrint (eLogWarning, "NetDb: LeaseSet update failed: ", ident.ToBase32());
m_LeaseSets.erase (it);
}
LogPrint(eLogDebug, "NetDb: LeaseSet is older: ", ident.ToBase32());
}
else
LogPrint (eLogDebug, "NetDb: LeaseSet is older: ", ident.ToBase32());
LogPrint(eLogError, "NetDb: LeaseSet is invalid: ", ident.ToBase32());
}
else
{