Skip to content

Commit fbcfb95

Browse files
committed
Set protection against zero block offset
1 parent 32a9bc4 commit fbcfb95

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

explorer/adapter.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class Adapter : public Node::IObserver, public IAdapter {
249249
_quote.data += 3;
250250
}
251251

252-
static const uint64_t s_TotalsVer = 1;
252+
static const uint64_t s_TotalsVer = 2;
253253

254254
void Initialize() override
255255
{
@@ -471,6 +471,12 @@ class Adapter : public Node::IObserver, public IAdapter {
471471

472472
if (bForceReset)
473473
{
474+
if (!lst.empty() && (lst.back().second.m_TotalOffset == sd.m_Extra0.m_TotalOffset))
475+
{
476+
CorruptionException exc;
477+
exc.m_sErr = "zero offset detected. Full Reset is required to recover";
478+
throw exc;
479+
}
474480
}
475481
else
476482
{

node/processor.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,6 +3147,13 @@ bool NodeProcessor::HandleBlockInternal(const HeightHash& id, const Block::Syste
31473147

31483148
if (bFirstTime)
31493149
{
3150+
if (block.m_Offset.m_Value == Zero)
3151+
{
3152+
BEAM_LOG_WARNING() << id << " has zero offset";
3153+
return false;
3154+
}
3155+
3156+
31503157
pShared->m_Size = bufs.m_Perishable.size() + bufs.m_Eternal.size();
31513158
pShared->m_Ctx.m_Height = id.m_Height;
31523159

0 commit comments

Comments
 (0)