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

Fix range check to avoid index out of range panic #9

Merged
merged 2 commits into from
Feb 7, 2020

Conversation

divergentdave
Copy link
Contributor

My server crashed with panic: runtime error: index out of range due to an incorrect range check. This PR should fix it by making sure there's enough buffer before reading a length value out of the SNI extension.

Error message and stack trace:

Mar 12 21:12:57 raspberrypi sniff[454]: 2017/03/12 21:12:57 Error: EOF
Mar 12 21:12:58 raspberrypi sniff[454]: 2017/03/12 21:12:58 Error: read tcp 192.175.111.254:5831: connection reset by peer
Mar 12 21:13:00 raspberrypi sniff[454]: 2017/03/12 21:13:00 Error: EOF
Mar 12 21:13:01 raspberrypi sniff[454]: 2017/03/12 21:13:01 Error: read tcp 192.175.111.254:26998: connection reset by peer
Mar 12 21:13:06 raspberrypi sniff[454]: panic: runtime error: index out of range
Mar 12 21:13:06 raspberrypi sniff[454]: goroutine 25485 [running]:
Mar 12 21:13:06 raspberrypi sniff[454]: pault.ag/go/sniff/parser.GetSNBlock(0x1046d0dc, 0x29, 0xf24, 0x0, 0x0, 0x0, 0x0, 0x0)
Mar 12 21:13:06 raspberrypi sniff[454]: /home/pi/go/src/pault.ag/go/sniff/parser/parser.go:91 +0x224
Mar 12 21:13:06 raspberrypi sniff[454]: pault.ag/go/sniff/parser.GetHostname(0x1046d000, 0x1000, 0x1000, 0x0, 0x0, 0x0, 0x0)
Mar 12 21:13:06 raspberrypi sniff[454]: /home/pi/go/src/pault.ag/go/sniff/parser/parser.go:42 +0xe0
Mar 12 21:13:06 raspberrypi sniff[454]: main.(*Proxy).Handle(0x104362a0, 0xb6d39a10, 0x1040a330)
Mar 12 21:13:06 raspberrypi sniff[454]: /home/pi/go/src/github.com/divergentdave/sniff/server.go:110 +0x174
Mar 12 21:13:06 raspberrypi sniff[454]: created by main.(*Config).Serve
Mar 12 21:13:06 raspberrypi sniff[454]: /home/pi/go/src/github.com/divergentdave/sniff/server.go:97 +0x2a0
...

@paultag
Copy link
Owner

paultag commented Feb 6, 2020

This has some conflicts, mind resolving? Sorry for not seeing this, thanks for the PR!

@divergentdave
Copy link
Contributor Author

Here you go!

@paultag paultag merged commit cf7e4d1 into paultag:master Feb 7, 2020
@paultag
Copy link
Owner

paultag commented Feb 7, 2020

Thank you! Longest time to merge ever.

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

Successfully merging this pull request may close these issues.

2 participants