Skip to content

Commit

Permalink
eth/protocols/eth: added td length check (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVanDerWijden authored Nov 23, 2020
1 parent 72950e8 commit 914d0e2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions eth/protocols/eth/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ func (p *Peer) Handshake(network uint64, td *big.Int, head common.Hash, genesis
default:
panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version))
}
// TD at mainnet block #7753254 is 76 bits. If it becomes 100 million times
// larger, it will still fit within 100 bits
if tdlen := p.td.BitLen(); tdlen > 100 {
return fmt.Errorf("too large block TD: bitlen %d", tdlen)
}
return nil
}

Expand Down

0 comments on commit 914d0e2

Please sign in to comment.