github-vet / github-vet/rangeloop-pointer-findings

xushiwei/go.old: src/pkg/crypto/tls/handshake_client.go; 31 LoC

Open
#11,680 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [xushiwei/go.old](https://www.github.com/xushiwei/go.old) at [src/pkg/crypto/tls/handshake_client.go](https://github.com/xushiwei/go.old/blob/f26f6dff6d01f2a36ae3e1dba7261a6ea3a89f44/src/pkg/crypto/tls/handshake_client.go#L200-L230)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.

> reference to cert is reassigned at line 226

[Click here to see the code in its original context.](https://github.com/xushiwei/go.old/blob/f26f6dff6d01f2a36ae3e1dba7261a6ea3a89f44/src/pkg/crypto/tls/handshake_client.go#L200-L230)

Click here to show the 31 line(s) of Go which triggered the analyzer.

```go
for i, cert := range c.config.Certificates {
if !rsaAvail {
continue
}

leaf := cert.Leaf
if leaf == nil {
if leaf, err = x509.ParseCertificate(cert.Certificate[0]); err != nil {
c.sendAlert(alertInternalError)
return errors.New("tls: failed to parse client certificate #" + strconv.Itoa(i) + ": " + err.Error())
}
}

if leaf.PublicKeyAlgorithm != x509.RSA {
continue
}

if len(certReq.certificateAuthorities) == 0 {
// they gave us an empty list, so just take the
// first RSA cert from c.config.Certificates
certToSend = &cert
break
}

for _, ca := range certReq.certificateAuthorities {
if bytes.Equal(leaf.RawIssuer, ca) {
certToSend = &cert
break findCert
}
}
}

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: f26f6dff6d01f2a36ae3e1dba7261a6ea3a89f44

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.