diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-11-24 20:46:59 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-11-24 20:46:59 +0000 |
commit | ada817453c6d0f3cb24c96769c8827a4bcdc3d99 (patch) | |
tree | 8df09f3b05096fb584b8cc8c7919a404fbb3db1a /libgo | |
parent | 9dbc5ff0711a5e6a0b70968a698d51d30876f2ff (diff) | |
download | gcc-ada817453c6d0f3cb24c96769c8827a4bcdc3d99.tar.gz |
syscall: Fix handling of Unix domain @ addresses.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193783 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/go/syscall/socket.go | 6 | ||||
-rw-r--r-- | libgo/go/syscall/socket_linux.go | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/libgo/go/syscall/socket.go b/libgo/go/syscall/socket.go index 819e70a46d3..3aa92012f08 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 cd7d6eb98b9..49a1625d08d 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++ } |