Skip to content

Commit

Permalink
Fix controller nil pointer deref
Browse files Browse the repository at this point in the history
  • Loading branch information
Kexort committed May 13, 2024
1 parent 7960a49 commit 81e3b04
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pkg/dynamicaccess/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 81e3b04

Please sign in to comment.