summaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-07-24 16:53:17 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-07-24 16:53:17 +0000
commit9612f3980812ea5058080798c20f2cc5f3f609fe (patch)
treeed13d57ba29d665908e53c726aa0dfdabc4d40d7 /libgo
parent0542766976e4d9b2d2d460625ad9a7732d04b64a (diff)
downloadgcc-9612f3980812ea5058080798c20f2cc5f3f609fe.tar.gz
net: Only use GNU/Linux unix socket abstract paths on GNU/Linux.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201217 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/syscall/socket.go6
-rw-r--r--libgo/go/syscall/socket_bsd.go38
-rw-r--r--libgo/go/syscall/socket_irix.go4
-rw-r--r--libgo/go/syscall/socket_linux.go9
-rw-r--r--libgo/go/syscall/socket_solaris.go39
5 files changed, 49 insertions, 47 deletions
diff --git a/libgo/go/syscall/socket.go b/libgo/go/syscall/socket.go
index cf0c08ebbf8..cc98d6b79fd 100644
--- a/libgo/go/syscall/socket.go
+++ b/libgo/go/syscall/socket.go
@@ -92,11 +92,7 @@ func (sa *SockaddrUnix) sockaddr() (*RawSockaddrAny, Socklen_t, error) {
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 --git a/libgo/go/syscall/socket_bsd.go b/libgo/go/syscall/socket_bsd.go
index be559915951..72d7180b6ed 100644
--- a/libgo/go/syscall/socket_bsd.go
+++ b/libgo/go/syscall/socket_bsd.go
@@ -11,11 +11,11 @@ const SizeofSockaddrInet6 = 28
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 @@ func (sa *RawSockaddrInet4) setLen() Socklen_t {
}
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 @@ func (sa *RawSockaddrInet6) setLen() Socklen_t {
}
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 @@ func (sa *RawSockaddrUnix) getLen() (int, error) {
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 --git a/libgo/go/syscall/socket_irix.go b/libgo/go/syscall/socket_irix.go
index 289769b6d3f..bcd1781d570 100644
--- a/libgo/go/syscall/socket_irix.go
+++ b/libgo/go/syscall/socket_irix.go
@@ -64,6 +64,10 @@ func (sa *RawSockaddrUnix) getLen() (int, error) {
return n, nil
}
+func (sa *RawSockaddrUnix) adjustAbstract(sl Socklen_t) Socklen_t {
+ return sl
+}
+
type RawSockaddr struct {
Family uint16
Data [14]int8
diff --git a/libgo/go/syscall/socket_linux.go b/libgo/go/syscall/socket_linux.go
index 49a1625d08d..8546abc3e06 100644
--- a/libgo/go/syscall/socket_linux.go
+++ b/libgo/go/syscall/socket_linux.go
@@ -110,6 +110,15 @@ func (sa *RawSockaddrUnix) getLen() (int, error) {
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 --git a/libgo/go/syscall/socket_solaris.go b/libgo/go/syscall/socket_solaris.go
index 0a03465a338..39588892f2b 100644
--- a/libgo/go/syscall/socket_solaris.go
+++ b/libgo/go/syscall/socket_solaris.go
@@ -12,9 +12,9 @@ const SizeofSockaddrUnix = 110
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 @@ func (sa *RawSockaddrInet4) setLen() Socklen_t {
}
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 @@ func (sa *RawSockaddrInet6) setLen() Socklen_t {
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
}
+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.