Skip to content

Commit

Permalink
restrict maketx call to realm only
Browse files Browse the repository at this point in the history
  • Loading branch information
thinhnx-var committed May 30, 2024
1 parent 11348f7 commit defc250
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 0 additions & 6 deletions gno.land/pkg/keyscli/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ func execMakeCall(cfg *MakeCallCfg, args []string, io commands.IO) error {
if cfg.PkgPath == "" {
return errors.New("pkgpath not specified")
}
if len(cfg.PkgPath) < 10 || cfg.PkgPath[:9] != "gno.land/" {
return errors.New("pkgpath should starts with gno.land/")
}
if len(cfg.PkgPath) >= 10 && (cfg.PkgPath[:10] == "gno.land/p" || cfg.PkgPath[:11] == "gno.land/p/") {
return errors.New("called to /p is forbidden")
}
if cfg.FuncName == "" {
return errors.New("func not specified")
}
Expand Down
3 changes: 3 additions & 0 deletions gno.land/pkg/sdk/vm/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ func (vm *VMKeeper) AddPackage(ctx sdk.Context, msg MsgAddPackage) (err error) {
// Call calls a public Gno function (for delivertx).
func (vm *VMKeeper) Call(ctx sdk.Context, msg MsgCall) (res string, err error) {
pkgPath := msg.PkgPath // to import
if !gno.IsRealmPath(pkgPath) {
return "", errors.New("pkgpath must be a realm")
}
fnc := msg.Func
gnostore := vm.getGnoStore(ctx)
// Get the package and function type.
Expand Down

0 comments on commit defc250

Please sign in to comment.