-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Minor bug #54
Minor bug #54
Conversation
Thanks for the PR! I do not fully understand the bug. Why does it happen and why does the change fix it? |
A snippet of code would be more clear.
Output:
|
Ah I see! THAT is a tricky one! :D One more question: wouldn't we need to change the line on 58,59,86 as well? |
socks/socks.go
Outdated
@@ -82,7 +82,7 @@ func ReadAddr(r io.Reader) (Addr, error) { | |||
if err != nil { | |||
return nil, err | |||
} | |||
_, err = io.ReadFull(r, b[2:2+b[1]+2]) | |||
_, err = io.ReadFull(r, b[2:2+int(b[1])+2]) | |||
return b[:1+1+b[1]+2], err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be b[:1+1+int(b[1])+2]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the right way to parse the address.
Thanks a lot! |
But it causes runtime panic when indexing specific size domain name
`panic: runtime error: slice bounds out of range
goroutine 2026854 [running]:
github.com/shadowsocks/go-shadowsocks2/socks.ReadAddr(0x7f3db541df80, 0xc429c676e0, 0xc429c676e0, 0x7f3db541df80, 0xc429c676e0, 0x0, 0xc420021f30)`