From 0896ff6fa4ce61792a0f883bf58066d2415779be Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 9 Mar 2026 01:23:53 -0700 Subject: [PATCH] fix: add nil/empty group validation in memory store Guard CreateGroup and UpdateGroup against nil group or empty name to prevent panics from nil pointer dereference on map access. --- weed/credential/memory/memory_group.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/weed/credential/memory/memory_group.go b/weed/credential/memory/memory_group.go index 180ce51c5..b9e1ca067 100644 --- a/weed/credential/memory/memory_group.go +++ b/weed/credential/memory/memory_group.go @@ -2,6 +2,7 @@ package memory import ( "context" + "fmt" "github.com/seaweedfs/seaweedfs/weed/credential" "github.com/seaweedfs/seaweedfs/weed/pb/iam_pb" @@ -28,6 +29,9 @@ func cloneGroup(g *iam_pb.Group) *iam_pb.Group { } func (store *MemoryStore) CreateGroup(ctx context.Context, group *iam_pb.Group) error { + if group == nil || group.Name == "" { + return fmt.Errorf("group name is required") + } store.mu.Lock() defer store.mu.Unlock() @@ -71,6 +75,9 @@ func (store *MemoryStore) ListGroups(ctx context.Context) ([]string, error) { } func (store *MemoryStore) UpdateGroup(ctx context.Context, group *iam_pb.Group) error { + if group == nil || group.Name == "" { + return fmt.Errorf("group name is required") + } store.mu.Lock() defer store.mu.Unlock()