Skip to content

Commit 8d6cc16

Browse files
authored
cmd/geth: check block range against chain head in export cmd (#22387)
Check the input parameters against the actual head block, exit on error
1 parent 0c70b83 commit 8d6cc16

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎cmd/geth/chaincmd.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ func exportChain(ctx *cli.Context) error {
322322
if first < 0 || last < 0 {
323323
utils.Fatalf("Export error: block number must be greater than 0\n")
324324
}
325+
if head := chain.CurrentFastBlock(); uint64(last) > head.NumberU64() {
326+
utils.Fatalf("Export error: block number %d larger than head block %d\n", uint64(last), head.NumberU64())
327+
}
325328
err = utils.ExportAppendChain(chain, fp, uint64(first), uint64(last))
326329
}
327330

0 commit comments

Comments
 (0)