diff -r 144124fe5596 libgo/go/syscall/socket.go --- a/libgo/go/syscall/socket.go Wed Jul 24 06:18:23 2013 -0700 +++ b/libgo/go/syscall/socket.go Wed Jul 24 09:48:58 2013 -0700 @@ -92,11 +92,7 @@ if n > 0 { sl += Socklen_t(n) + 1 } - if sa.raw.Path[0] == '@' { - sa.raw.Path[0] = 0 - // Don't count trailing NUL for abstract address. - sl-- - } + sl = sa.raw.adjustAbstract(sl) // length is family (uint16), name, NUL. return (*RawSockaddrAny)(unsafe.Pointer(&sa.raw)), sl, nil diff -r 144124fe5596 libgo/go/syscall/socket_bsd.go --- a/libgo/go/syscall/socket_bsd.go Wed Jul 24 06:18:23 2013 -0700 +++ b/libgo/go/syscall/socket_bsd.go Wed Jul 24 09:48:58 2013 -0700 @@ -11,11 +11,11 @@ const SizeofSockaddrUnix = 110 type RawSockaddrInet4 struct { - Len uint8; - Family uint8; - Port uint16; - Addr [4]byte /* in_addr */; - Zero [8]uint8; + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 } func (sa *RawSockaddrInet4) setLen() Socklen_t { @@ -24,12 +24,12 @@ } type RawSockaddrInet6 struct { - Len uint8; - Family uint8; - Port uint16; - Flowinfo uint32; - Addr [16]byte /* in6_addr */; - Scope_id uint32; + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 } func (sa *RawSockaddrInet6) setLen() Socklen_t { @@ -38,9 +38,9 @@ } type RawSockaddrUnix struct { - Len uint8; - Family uint8; - Path [108]int8; + Len uint8 + Family uint8 + Path [108]int8 } func (sa *RawSockaddrUnix) setLen(n int) { @@ -62,10 +62,14 @@ return n, nil } +func (sa *RawSockaddrUnix) adjustAbstract(sl Socklen_t) Socklen_t { + return sl +} + type RawSockaddr struct { - Len uint8; - Family uint8; - Data [14]int8; + Len uint8 + Family uint8 + Data [14]int8 } // BindToDevice binds the socket associated with fd to device. diff -r 144124fe5596 libgo/go/syscall/socket_irix.go --- a/libgo/go/syscall/socket_irix.go Wed Jul 24 06:18:23 2013 -0700 +++ b/libgo/go/syscall/socket_irix.go Wed Jul 24 09:48:58 2013 -0700 @@ -64,6 +64,10 @@ return n, nil } +func (sa *RawSockaddrUnix) adjustAbstract(sl Socklen_t) Socklen_t { + return sl +} + type RawSockaddr struct { Family uint16 Data [14]int8 diff -r 144124fe5596 libgo/go/syscall/socket_linux.go --- a/libgo/go/syscall/socket_linux.go Wed Jul 24 06:18:23 2013 -0700 +++ b/libgo/go/syscall/socket_linux.go Wed Jul 24 09:48:58 2013 -0700 @@ -110,6 +110,15 @@ return n, nil } +func (sa *RawSockaddrUnix) adjustAbstract(sl Socklen_t) Socklen_t { + if sa.Path[0] == '@' { + sa.Path[0] = 0 + // Don't count trailing NUL for abstract address. + sl-- + } + return sl +} + type RawSockaddrLinklayer struct { Family uint16 Protocol uint16 diff -r 144124fe5596 libgo/go/syscall/socket_solaris.go --- a/libgo/go/syscall/socket_solaris.go Wed Jul 24 06:18:23 2013 -0700 +++ b/libgo/go/syscall/socket_solaris.go Wed Jul 24 09:48:58 2013 -0700 @@ -12,9 +12,9 @@ type RawSockaddrInet4 struct { Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 } func (sa *RawSockaddrInet4) setLen() Socklen_t { @@ -22,12 +22,12 @@ } type RawSockaddrInet6 struct { - Family uint16 - Port uint16 + Family uint16 + Port uint16 Flowinfo uint32 - Addr [16]byte /* in6_addr */ + Addr [16]byte /* in6_addr */ Scope_id uint32 - Src_id uint32 + Src_id uint32 } func (sa *RawSockaddrInet6) setLen() Socklen_t { @@ -36,38 +36,27 @@ type RawSockaddrUnix struct { Family uint16 - Path [108]int8 + Path [108]int8 } func (sa *RawSockaddrUnix) setLen(int) { } func (sa *RawSockaddrUnix) getLen() (int, error) { - if sa.Path[0] == 0 { - // "Abstract" Unix domain socket. - // Rewrite leading NUL as @ for textual display. - // (This is the standard convention.) - // Not friendly to overwrite in place, - // but the callers below don't care. - sa.Path[0] = '@' - } - - // Assume path ends at NUL. - // This is not technically the GNU/Linux semantics for - // abstract Unix domain sockets--they are supposed - // to be uninterpreted fixed-size binary blobs--but - // everyone uses this convention. n := 0 - for n < len(sa.Path) - 3 && sa.Path[n] != 0 { + for n < len(sa.Path) && sa.Path[n] != 0 { n++ } + return n, nil +} - return n, nil +func (sa *RawSockaddrUnix) adjustAbstract(sl Socklen_t) Socklen_t { + return sl } type RawSockaddr struct { Family uint16 - Data [14]int8 + Data [14]int8 } // BindToDevice binds the socket associated with fd to device.