Fix comparator that could cause a panic

This commit is contained in:
Steven Roose 2017-06-06 18:35:57 +02:00 committed by Dave Collins
parent bf43e56f2f
commit ef87de9d88

View file

@ -99,7 +99,7 @@ func TorLookupIP(host, proxy string) ([]net.IP, error) {
return nil, ErrTorInvalidProxyResponse return nil, ErrTorInvalidProxyResponse
} }
if buf[1] != 0 { if buf[1] != 0 {
if int(buf[1]) > len(torStatusErrors) { if int(buf[1]) >= len(torStatusErrors) {
return nil, ErrTorInvalidProxyResponse return nil, ErrTorInvalidProxyResponse
} else if err := torStatusErrors[buf[1]]; err != nil { } else if err := torStatusErrors[buf[1]]; err != nil {
return nil, err return nil, err