From f9bcb6f5e35ada86eea74e38506600c1837254a3 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 6 Dec 2021 18:24:53 +0300 Subject: [PATCH] [#1007] metabase: Copy BoltDB value returned by IsSmall According to BoltDB documentation bucket `value is only valid for the life of the transaction`. Make `DB.IsSmall` copy value slice in order to prevent potential memory corruptions (e.g. `runtime.stringtobyteslice` cast). Signed-off-by: Leonard Lyubich --- pkg/local_object_storage/metabase/small.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/local_object_storage/metabase/small.go b/pkg/local_object_storage/metabase/small.go index 48b73462a..1ce59aac7 100644 --- a/pkg/local_object_storage/metabase/small.go +++ b/pkg/local_object_storage/metabase/small.go @@ -1,6 +1,7 @@ package meta import ( + "github.com/nspcc-dev/neo-go/pkg/util/slice" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" "go.etcd.io/bbolt" @@ -69,5 +70,5 @@ func (db *DB) isSmall(tx *bbolt.Tx, addr *objectSDK.Address) (*blobovnicza.ID, e return nil, nil } - return blobovnicza.NewIDFromBytes(blobovniczaID), nil + return blobovnicza.NewIDFromBytes(slice.Copy(blobovniczaID)), nil }