Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/x509: when TestEnvVars fails, it "index out of range" panics due to off-by-one bug #20801

Closed
dmitshur opened this issue Jun 26, 2017 · 1 comment

Comments

@dmitshur
Copy link
Contributor

dmitshur commented Jun 26, 2017

I already reported the issue in the CL where it was introduced. /cc @stevenh @bradfitz Creating this issue for posterity, so I can reference it in the CL I'm about to send.

TestEnvVars contains this code:

for i, cn := range tc.cns {
	if i > len(r.certs) {
		t.Errorf("missing cert %v @ %v", cn, i)
	} else if r.certs[i].Subject.CommonName != cn {
		// ...
	}
}

It should have i >= len(r.certs) instead, otherwise r.certs[i] in the else if will panic when i == len(r.certs).

This panic happens when the test fails due to the returned number of certificates (r.certs) being less than expected by test case (tc.cns).

CL upcoming. Edit: Sent CL 46715.

@gopherbot
Copy link

CL https://golang.org/cl/46715 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants