mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-06 19:55:10 +00:00
core: check for permission in System.Contract.Call(Ex)
This commit is contained in:
parent
5514b3f52f
commit
c69f8a2fa3
2 changed files with 13 additions and 13 deletions
|
@ -484,12 +484,21 @@ func contractCallExInternal(ic *interop.Context, v *vm.VM, h []byte, method stac
|
|||
if err != nil {
|
||||
return errors.New("invalid contract hash")
|
||||
}
|
||||
script := ic.GetContract(u)
|
||||
if script == nil {
|
||||
cs, err := ic.DAO.GetContractState(u)
|
||||
if err != nil {
|
||||
return errors.New("contract not found")
|
||||
}
|
||||
// TODO perform flags checking after #923
|
||||
v.LoadScript(script)
|
||||
bs, err := method.TryBytes()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
curr, err := ic.DAO.GetContractState(v.GetCurrentScriptHash())
|
||||
if err == nil {
|
||||
if !curr.Manifest.CanCall(&cs.Manifest, string(bs)) {
|
||||
return errors.New("disallowed method call")
|
||||
}
|
||||
}
|
||||
v.LoadScript(cs.Script)
|
||||
v.Estack().PushVal(args)
|
||||
v.Estack().PushVal(method)
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue