Skip to content

Commit

Permalink
tidy: double check generated connection IDs are unique
Browse files Browse the repository at this point in the history
  • Loading branch information
tinyzimmer committed Nov 11, 2023
1 parent 3ba1f2e commit c7a3618
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/cmd/daemoncmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ func (app *AppDaemon) PutConnection(ctx context.Context, req *v1.PutConnectionRe
return nil, status.Errorf(codes.Internal, "failed to generate connection ID: %v", err)
}
profileID = ProfileID(id)
// Double check that the generated ID is unique
if _, err := app.connmgr.Profiles().Get(ctx, profileID); err == nil {
return nil, status.Errorf(codes.Internal, "generated connection ID is not unique: %v", profileID)
}
}
err = app.connmgr.Profiles().Put(ctx, profileID, Profile{req})
if err != nil {
Expand Down

0 comments on commit c7a3618

Please sign in to comment.