From 8d6cc1674252371c7441279fd9d482d9416dc8aa Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi <1591639+s1na@users.noreply.github.com> Date: Mon, 22 Mar 2021 19:11:10 +0100 Subject: [PATCH] cmd/geth: check block range against chain head in export cmd (#22387) Check the input parameters against the actual head block, exit on error --- cmd/geth/chaincmd.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 61401dd59..3cae32aa9 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -322,6 +322,9 @@ func exportChain(ctx *cli.Context) error { if first < 0 || last < 0 { utils.Fatalf("Export error: block number must be greater than 0\n") } + if head := chain.CurrentFastBlock(); uint64(last) > head.NumberU64() { + utils.Fatalf("Export error: block number %d larger than head block %d\n", uint64(last), head.NumberU64()) + } err = utils.ExportAppendChain(chain, fp, uint64(first), uint64(last)) }