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

dmitshur opened this issue Jun 26, 2017 · 1 comment


Copy link

@dmitshur 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.

Copy link

@gopherbot gopherbot commented Jun 26, 2017

CL mentions this issue.

@gopherbot gopherbot closed this in 441fd13 Jun 27, 2017
@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.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.