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

Error out on negative indices in element() #5263

Merged
merged 1 commit into from
Mar 16, 2016

Conversation

billf
Copy link
Contributor

@billf billf commented Feb 23, 2016

prevents a negative offset in StringList.Element():

return sl.Slice()[index%sl.Length()]

fixes the following crash:

panic: runtime error: index out of range

goroutine 5424 [running]:
panic(0xa00f20, 0xc82001a160)
    /usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:464 +0x3e6
github.com/hashicorp/terraform/config.StringList.Element(0xc8209c6300, 0x16a, 0xfffffffffffffffb, 0x0, 0x0)
    /Users/bill/goprojects/src/github.com/hashicorp/terraform/config/string_list.go:60 +0xef
github.com/hashicorp/terraform/config.interpolationFuncElement.func1(0xc820654e40, 0x2, 0x2, 0x0, 0x0, 0x0, 0x0)
    /Users/bill/goprojects/src/github.com/hashicorp/terraform/config/interpolate_funcs.go:483 +0x2bd
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hil.(*evalCall).Eval(0xc820ab63a0, 0x24c0a48, 0xc820e8d290, 0xc820f14dd0, 0x0, 0x0, 0x139aa58, 0x0, 0x0)
    /Users/bill/goprojects/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hil/eval.go:179 +0x41f
...

@jen20
Copy link
Contributor

jen20 commented Mar 16, 2016

Hi @billf! Thanks for opening this pull request - good catch!

jen20 added a commit that referenced this pull request Mar 16, 2016
Error out on negative indices in element()
@jen20 jen20 merged commit 87550b2 into hashicorp:master Mar 16, 2016
@jen20 jen20 added the crash label Mar 16, 2016
@billf billf deleted the b-element-negative branch August 9, 2016 05:08
@ghost
Copy link

ghost commented Apr 23, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants