Merge pull request #672 from nspcc-dev/fix-sigsegv-on-reference-check

core: deal with bad transaction Inputs
This commit is contained in:
Roman Khimov 2020-02-14 13:23:42 +03:00 committed by GitHub
commit b5453ad24f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -965,14 +965,15 @@ func (bc *Blockchain) References(t *transaction.Transaction) map[transaction.Inp
references := make(map[transaction.Input]*transaction.Output)
for prevHash, inputs := range t.GroupInputsByPrevHash() {
if tx, _, err := bc.dao.GetTransaction(prevHash); err != nil {
tx = nil
} else if tx != nil {
for _, in := range inputs {
references[*in] = &tx.Outputs[in.PrevIndex]
tx, _, err := bc.dao.GetTransaction(prevHash)
if err != nil {
return nil
}
for _, in := range inputs {
if int(in.PrevIndex) > len(tx.Outputs)-1 {
return nil
}
} else {
references = nil
references[*in] = &tx.Outputs[in.PrevIndex]
}
}
return references
@ -1451,7 +1452,7 @@ func (bc *Blockchain) GetScriptHashesForVerifying(t *transaction.Transaction) ([
}
references := bc.References(t)
if references == nil {
return nil, errors.New("Invalid operation")
return nil, errors.New("invalid inputs")
}
hashes := make(map[util.Uint160]bool)
for _, i := range t.Inputs {