syscall: Fix handling of Unix domain @ addresses.
From-SVN: r193783
This commit is contained in:
parent
f246eadc0a
commit
40ff695f5c
@ -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) {
|
||||
|
@ -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++
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user