From 869b277af1e37cac395a7475ee39cb12c9422491 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 20 Apr 2026 19:13:52 +0200 Subject: [PATCH] wincred: inline label, and append to existing The code assumed that Attributes was always empty, so unconditionally replaced the attributes. Let's not assume that's the case (even if it is currently). Also inline the label for readability; we could optimize the byte-slice by making a package level variable, to avoid allocating, but that's probably not worth the optimzation. Signed-off-by: Sebastiaan van Stijn --- wincred/wincred.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wincred/wincred.go b/wincred/wincred.go index 895d62dc..91b390fc 100644 --- a/wincred/wincred.go +++ b/wincred/wincred.go @@ -16,12 +16,14 @@ type Wincred struct{} // Add adds new credentials to the windows credentials manager. func (h Wincred) Add(creds *credentials.Credentials) error { - credsLabels := []byte(credentials.CredsLabel) g := winc.NewGenericCredential(creds.ServerURL) g.UserName = creds.Username g.CredentialBlob = []byte(creds.Secret) g.Persist = winc.PersistLocalMachine - g.Attributes = []winc.CredentialAttribute{{Keyword: "label", Value: credsLabels}} + g.Attributes = append(g.Attributes, winc.CredentialAttribute{ + Keyword: "label", + Value: []byte(credentials.CredsLabel), + }) return g.Write() }