Explorar o código

go.net/proxy: don't pass invalid domain name length to SOCKS5 proxies

SOCKS5 uses a single-byte field for domain name length. This change
causes dials to domain names longer than 255 chars to fail instead
of sending an invalid request to the proxy.

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/90790044
Robert Obryk %!s(int64=11) %!d(string=hai) anos
pai
achega
fbcd5c9bb3
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      proxy/socks5.go

+ 3 - 0
proxy/socks5.go

@@ -149,6 +149,9 @@ func (s *socks5) Dial(network, addr string) (net.Conn, error) {
 		}
 		buf = append(buf, ip...)
 	} else {
+		if len(host) > 255 {
+			return nil, errors.New("proxy: destination hostname too long: " + host)
+		}
 		buf = append(buf, socks5Domain)
 		buf = append(buf, byte(len(host)))
 		buf = append(buf, host...)