From 194da649751e5a7f4b946860f0c92b77b10f0fce Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 4 Aug 2020 10:13:36 +0300 Subject: [PATCH] core: deepcopy notification in `System.Runtime.Notify` Make it impossible to change already emitted notifications via `System.Runtime.GetNotifications`. --- pkg/core/interop/runtime/util.go | 2 +- pkg/core/interop_system.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/core/interop/runtime/util.go b/pkg/core/interop/runtime/util.go index 522940381..aef0f8ce8 100644 --- a/pkg/core/interop/runtime/util.go +++ b/pkg/core/interop/runtime/util.go @@ -47,7 +47,7 @@ func GetNotifications(ic *interop.Context, v *vm.VM) error { ev := stackitem.NewArray([]stackitem.Item{ stackitem.NewByteArray(notifications[i].ScriptHash.BytesBE()), stackitem.Make(notifications[i].Name), - notifications[i].Item, + stackitem.DeepCopy(notifications[i].Item).(*stackitem.Array), }) arr.Append(ev) } diff --git a/pkg/core/interop_system.go b/pkg/core/interop_system.go index 508d02bfb..242460ca0 100644 --- a/pkg/core/interop_system.go +++ b/pkg/core/interop_system.go @@ -282,7 +282,7 @@ func runtimeNotify(ic *interop.Context, v *vm.VM) error { ne := state.NotificationEvent{ ScriptHash: v.GetCurrentScriptHash(), Name: name, - Item: stackitem.NewArray(args), + Item: stackitem.DeepCopy(stackitem.NewArray(args)).(*stackitem.Array), } ic.Notifications = append(ic.Notifications, ne) return nil