cmd/geth: check block range against chain head in export cmd (#22387)

Check the input parameters against the actual head block, exit on error
revert-23120-drop-eth-65
Sina Mahmoodi 4 years ago committed by GitHub
parent 0c70b83e00
commit 8d6cc16742
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      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))
}

Loading…
Cancel
Save