core: check for key length in CheckWitness, fix #968

Only one type of keys is allowed here.
This commit is contained in:
Roman Khimov 2020-05-21 14:27:19 +03:00
parent d0853c0471
commit 0ce3a12e87

View file

@ -322,6 +322,10 @@ func (ic *interopContext) runtimeCheckWitness(v *vm.VM) error {
hashOrKey := v.Estack().Pop().Bytes()
hash, err := util.Uint160DecodeBytesBE(hashOrKey)
if err != nil {
// We only accept compressed keys here as per C# implementation.
if len(hashOrKey) != 33 {
return errors.New("bad parameter length")
}
key := &keys.PublicKey{}
err = key.DecodeBytes(hashOrKey)
if err != nil {