aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-11-24 20:46:59 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-11-24 20:46:59 +0000
commit40ff695f5cb23ff4313d5a22c5e97f971e4bd65b (patch)
tree8df09f3b05096fb584b8cc8c7919a404fbb3db1a /libgo
parentf246eadc0acadb23e08a86f71177cff7596cfc87 (diff)
downloadgcc-40ff695f5cb23ff4313d5a22c5e97f971e4bd65b.zip
gcc-40ff695f5cb23ff4313d5a22c5e97f971e4bd65b.tar.gz
gcc-40ff695f5cb23ff4313d5a22c5e97f971e4bd65b.tar.bz2
syscall: Fix handling of Unix domain @ addresses.
From-SVN: r193783
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/syscall/socket.go6
-rw-r--r--libgo/go/syscall/socket_linux.go2
2 files changed, 6 insertions, 2 deletions
diff --git a/libgo/go/syscall/socket.go b/libgo/go/syscall/socket.go
index 819e70a..3aa92012 100644
--- a/libgo/go/syscall/socket.go
+++ b/libgo/go/syscall/socket.go
@@ -87,12 +87,16 @@ func (sa *SockaddrUnix) sockaddr() (*RawSockaddrAny, Socklen_t, error) {
for i := 0; i < n; i++ {
sa.raw.Path[i] = int8(name[i])
}
+ // length is family (uint16), name, NUL.
+ sl := 2 + Socklen_t(n) + 1
if sa.raw.Path[0] == '@' {
sa.raw.Path[0] = 0
+ // Don't count trailing NUL for abstract address.
+ sl--
}
// length is family (uint16), name, NUL.
- return (*RawSockaddrAny)(unsafe.Pointer(&sa.raw)), 2 + Socklen_t(n) + 1, nil
+ return (*RawSockaddrAny)(unsafe.Pointer(&sa.raw)), sl, nil
}
func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
diff --git a/libgo/go/syscall/socket_linux.go b/libgo/go/syscall/socket_linux.go
index cd7d6eb..49a1625 100644
--- a/libgo/go/syscall/socket_linux.go
+++ b/libgo/go/syscall/socket_linux.go
@@ -103,7 +103,7 @@ func (sa *RawSockaddrUnix) getLen() (int, error) {
// 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++
}