Skip to content

Commit

Permalink
Merge pull request shadowsocks#54 from namaho/master
Browse files Browse the repository at this point in the history
Fixed a bug that truncates domain names with length over 251 bytes.
  • Loading branch information
riobard authored Jun 20, 2017
2 parents 9baef5e + a2d93e5 commit 4ad831b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions socks/socks.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func (a Addr) String() string {

switch a[0] { // address type
case AtypDomainName:
host = string(a[2 : 2+a[1]])
port = strconv.Itoa((int(a[2+a[1]]) << 8) | int(a[2+a[1]+1]))
host = string(a[2 : 2+int(a[1])])
port = strconv.Itoa((int(a[2+int(a[1])]) << 8) | int(a[2+int(a[1])+1]))
case AtypIPv4:
host = net.IP(a[1 : 1+net.IPv4len]).String()
port = strconv.Itoa((int(a[1+net.IPv4len]) << 8) | int(a[1+net.IPv4len+1]))
Expand All @@ -82,8 +82,8 @@ func ReadAddr(r io.Reader) (Addr, error) {
if err != nil {
return nil, err
}
_, err = io.ReadFull(r, b[2:2+b[1]+2])
return b[:1+1+b[1]+2], err
_, err = io.ReadFull(r, b[2:2+int(b[1])+2])
return b[:1+1+int(b[1])+2], err
case AtypIPv4:
_, err = io.ReadFull(r, b[1:1+net.IPv4len+2])
return b[:1+net.IPv4len+2], err
Expand Down

0 comments on commit 4ad831b

Please sign in to comment.