nef: limit the number of bytes to be read during decode

This commit is contained in:
Roman Khimov 2020-10-07 18:30:44 +03:00
parent 63c7469dfd
commit f45c032eff

View file

@ -203,11 +203,7 @@ func (n *File) DecodeBinary(r *io.BinReader) {
r.Err = errors.New("CRC verification fail") r.Err = errors.New("CRC verification fail")
return return
} }
n.Script = r.ReadVarBytes() n.Script = r.ReadVarBytes(MaxScriptLength)
if len(n.Script) > MaxScriptLength {
r.Err = errors.New("invalid script length")
return
}
if !hash.Hash160(n.Script).Equals(n.Header.ScriptHash) { if !hash.Hash160(n.Script).Equals(n.Header.ScriptHash) {
r.Err = errors.New("script hashes mismatch") r.Err = errors.New("script hashes mismatch")
return return