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

Server doesn't handle negative offset and/or limit given to Connz #491

Closed
kozlovic opened this issue May 17, 2017 · 0 comments
Closed

Server doesn't handle negative offset and/or limit given to Connz #491

kozlovic opened this issue May 17, 2017 · 0 comments
Assignees

Comments

@kozlovic
Copy link
Member

If server is started with monitoring on, and an user queries the connz endpoint with negative offset and/or limit, the server will report this for the current go-routine handling the request. The server is still working properly (does not entirely panic) and other well formed requests will go through.

For instance: http://localhost:8222/connz?offset=-1 produces this:

2017/05/17 11:19:42 http: panic serving [::1]:60778: runtime error: slice bounds out of range
goroutine 34 [running]:
net/http.(*conn).serve.func1(0xc42016c000)
	/usr/local/go/src/net/http/server.go:1491 +0x12a
panic(0x350c80, 0xc420012100)
	/usr/local/go/src/runtime/panic.go:458 +0x243
github.com/nats-io/gnatsd/server.(*Server).HandleConnz(0xc420136280, 0x544820, 0xc4201a40d0, 0xc42019a000)
	/Users/ivan/dev/go/src/github.com/nats-io/gnatsd/server/monitor.go:150 +0x19fb
github.com/nats-io/gnatsd/server.(*Server).HandleConnz-fm(0x544820, 0xc4201a40d0, 0xc42019a000)
	/Users/ivan/dev/go/src/github.com/nats-io/gnatsd/server/server.go:492 +0x48
net/http.HandlerFunc.ServeHTTP(0xc420013550, 0x544820, 0xc4201a40d0, 0xc42019a000)
	/usr/local/go/src/net/http/server.go:1726 +0x44
net/http.(*ServeMux).ServeHTTP(0xc42000d650, 0x544820, 0xc4201a40d0, 0xc42019a000)
	/usr/local/go/src/net/http/server.go:2022 +0x7f
net/http.serverHandler.ServeHTTP(0xc420096380, 0x544820, 0xc4201a40d0, 0xc42019a000)
	/usr/local/go/src/net/http/server.go:2202 +0x7d
net/http.(*conn).serve(0xc42016c000, 0x544fa0, 0xc42017e080)
	/usr/local/go/src/net/http/server.go:1579 +0x4b7
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2293 +0x44d
@kozlovic kozlovic self-assigned this May 17, 2017
@kozlovic kozlovic added the bug label May 17, 2017
kozlovic added a commit that referenced this issue May 17, 2017
Ensure that if the offset is negative, it is set to 0. If the limit
is negative, it is set to the default value.

Resolves #491
@ghost ghost added the waffle:needs review label May 17, 2017
@ghost ghost removed in progress labels May 18, 2017
@bruth bruth removed the 🐞 bug label Aug 18, 2023
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

2 participants