Browse Source

rpc: better arg validation for /tx

pull/412/head
Ethan Buchman 8 years ago
parent
commit
c848056438
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      rpc/core/tx.go

+ 5
- 1
rpc/core/tx.go View File

@ -29,9 +29,13 @@ func Tx(hash []byte, height, index int, prove bool) (*ctypes.ResultTx, error) {
deliverTx = r.DeliverTx
}
if height <= 0 || height > blockStore.Height() {
return nil, fmt.Errorf("Invalid height (%d) for blockStore at height %d", height, blockStore.Height())
}
block := blockStore.LoadBlock(height)
if index >= len(block.Data.Txs) {
if index < 0 || index >= len(block.Data.Txs) {
return nil, fmt.Errorf("Index (%d) is out of range for block (%d) with %d txs", index, height, len(block.Data.Txs))
}
tx := block.Data.Txs[index]


Loading…
Cancel
Save