From 6eb353c804f1b098575ab64e4dd24e231e8ab12c Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 30 Sep 2020 20:54:25 +0300 Subject: [PATCH] [#58] object/put: Validate payload content after filling Signed-off-by: Leonard Lyubich --- pkg/services/object/put/distributed.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/services/object/put/distributed.go b/pkg/services/object/put/distributed.go index 9faa8f7f..bcc51516 100644 --- a/pkg/services/object/put/distributed.go +++ b/pkg/services/object/put/distributed.go @@ -21,6 +21,8 @@ type distributedTarget struct { chunks [][]byte nodeTargetInitializer func(*network.Address) transformer.ObjectTarget + + fmt *object.FormatValidator } var errIncompletePut = errors.New("incomplete object put") @@ -57,6 +59,10 @@ func (t *distributedTarget) Close() (*transformer.AccessIdentifiers, error) { payload = append(payload, t.chunks[i]...) } + if err := t.fmt.ValidateContent(t.obj.GetType(), payload); err != nil { + return nil, errors.Wrapf(err, "(%T) could not validate payload content", t) + } + t.obj.SetPayload(payload) loop: