Skip to content

Commit

Permalink
chore: Appease gosec linter (#5777)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mholt authored Aug 24, 2023
1 parent 4776f62 commit b377208
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion modules/caddyhttp/reverseproxy/httptransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ func (t TLSConfig) MakeTLSClientConfig(ctx caddy.Context) (*tls.Config, error) {
certs := caddytls.AllMatchingCertificates(t.ClientCertificateAutomate)
var err error
for _, cert := range certs {
err = cri.SupportsCertificate(&cert.Certificate)
certCertificate := cert.Certificate // avoid taking address of iteration variable (gosec warning)
err = cri.SupportsCertificate(&certCertificate)
if err == nil {
return &cert.Certificate, nil
}
Expand Down
3 changes: 2 additions & 1 deletion modules/caddytls/certselection.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ nextChoice:
if len(p.SerialNumber) > 0 {
var found bool
for _, sn := range p.SerialNumber {
if cert.Leaf.SerialNumber.Cmp(&sn.Int) == 0 {
snInt := sn.Int // avoid taking address of iteration variable (gosec warning)
if cert.Leaf.SerialNumber.Cmp(&snInt) == 0 {
found = true
break
}
Expand Down

0 comments on commit b377208

Please sign in to comment.