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 and holiman committed Dec 11, 2020
1 parent 64dccdf commit 0180979
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 0180979

Please sign in to comment.