From 81e3b0417bbe202c1f501e5065c4a0300e3116a1 Mon Sep 17 00:00:00 2001 From: Kexort Date: Mon, 13 May 2024 14:54:37 +0200 Subject: [PATCH] Fix controller nil pointer deref --- pkg/dynamicaccess/controller.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pkg/dynamicaccess/controller.go b/pkg/dynamicaccess/controller.go index 5deb69c9ffe..a2c9ad50d04 100644 --- a/pkg/dynamicaccess/controller.go +++ b/pkg/dynamicaccess/controller.go @@ -162,6 +162,15 @@ func (c *controller) HandleGrantees( if err != nil { return swarm.ZeroAddress, swarm.ZeroAddress, swarm.ZeroAddress, swarm.ZeroAddress, err } + // generate new access key and new act + act, err = kvs.New(ls) + if err != nil { + return swarm.ZeroAddress, swarm.ZeroAddress, swarm.ZeroAddress, swarm.ZeroAddress, err + } + err = c.accessLogic.AddPublisher(ctx, act, publisher) + if err != nil { + return swarm.ZeroAddress, swarm.ZeroAddress, swarm.ZeroAddress, swarm.ZeroAddress, err + } } var gl GranteeList @@ -195,17 +204,15 @@ func (c *controller) HandleGrantees( } var granteesToAdd []*ecdsa.PublicKey - // generate new access key and new act if len(removeList) != 0 || encryptedglref.IsZero() { + // generate new access key and new act act, err = kvs.New(ls) if err != nil { return swarm.ZeroAddress, swarm.ZeroAddress, swarm.ZeroAddress, swarm.ZeroAddress, err } - if historyref.IsZero() { - err = c.accessLogic.AddPublisher(ctx, act, publisher) - if err != nil { - return swarm.ZeroAddress, swarm.ZeroAddress, swarm.ZeroAddress, swarm.ZeroAddress, err - } + err = c.accessLogic.AddPublisher(ctx, act, publisher) + if err != nil { + return swarm.ZeroAddress, swarm.ZeroAddress, swarm.ZeroAddress, swarm.ZeroAddress, err } granteesToAdd = gl.Get() } else {