Skip to content

Commit b377208

Browse files
authored
chore: Appease gosec linter (#5777)
These happen to be harmless memory aliasing but I guess the linter can't know that and we can't really prove it in general.
1 parent 4776f62 commit b377208

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

modules/caddyhttp/reverseproxy/httptransport.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,8 @@ func (t TLSConfig) MakeTLSClientConfig(ctx caddy.Context) (*tls.Config, error) {
529529
certs := caddytls.AllMatchingCertificates(t.ClientCertificateAutomate)
530530
var err error
531531
for _, cert := range certs {
532-
err = cri.SupportsCertificate(&cert.Certificate)
532+
certCertificate := cert.Certificate // avoid taking address of iteration variable (gosec warning)
533+
err = cri.SupportsCertificate(&certCertificate)
533534
if err == nil {
534535
return &cert.Certificate, nil
535536
}

modules/caddytls/certselection.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ nextChoice:
5858
if len(p.SerialNumber) > 0 {
5959
var found bool
6060
for _, sn := range p.SerialNumber {
61-
if cert.Leaf.SerialNumber.Cmp(&sn.Int) == 0 {
61+
snInt := sn.Int // avoid taking address of iteration variable (gosec warning)
62+
if cert.Leaf.SerialNumber.Cmp(&snInt) == 0 {
6263
found = true
6364
break
6465
}

0 commit comments

Comments
 (0)