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

panic: runtime error: slice bounds out of range [808:773] #541

Open
cbeuw opened this issue Nov 12, 2023 · 0 comments
Open

panic: runtime error: slice bounds out of range [808:773] #541

cbeuw opened this issue Nov 12, 2023 · 0 comments

Comments

@cbeuw
Copy link

cbeuw commented Nov 12, 2023

This panic happens when using the slicer toxic:

panic: runtime error: slice bounds out of range [808:773]

goroutine 114 [running]:
github.com/Shopify/toxiproxy/v2/toxics.(*SlicerToxic).Pipe(0x1400020c0f0, 0x1400021e480)
	github.com/Shopify/toxiproxy/v2/toxics/slicer.go:65 +0x320
github.com/Shopify/toxiproxy/v2/toxics.(*ToxicStub).Run(0x1400021e480, 0x14000210d20)
	github.com/Shopify/toxiproxy/v2/toxics/toxic.go:86 +0xb8
created by github.com/Shopify/toxiproxy/v2.(*ToxicLink).Start in goroutine 58
	github.com/Shopify/toxiproxy/v2/link.go:109 +0x2c8

The bug is here:

if t.SizeVariation > 0 {
mid += rand.Intn(t.SizeVariation*2) - t.SizeVariation
}

rand.Intn can return a number in [0, SizeVariation*2), so it can be less than SizeVariation, resulting a negative RHS and a mid less than start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant