1
0
mirror of https://github.com/golang/go synced 2024-11-21 15:34:45 -07:00

syscall: Correct length of GNU/Linux abstract Unix domain sockaddr.

R=rsc, iant2
CC=golang-dev
https://golang.org/cl/3974044
This commit is contained in:
Ian Lance Taylor 2011-01-18 08:10:22 -08:00
parent fa9befd777
commit 2862d003cb

View File

@ -253,12 +253,15 @@ func (sa *SockaddrUnix) sockaddr() (uintptr, _Socklen, int) {
for i := 0; i < n; i++ {
sa.raw.Path[i] = int8(name[i])
}
// length is family (uint16), name, NUL.
sl := 2 + _Socklen(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 uintptr(unsafe.Pointer(&sa.raw)), 2 + _Socklen(n) + 1, 0
return uintptr(unsafe.Pointer(&sa.raw)), sl, 0
}
type SockaddrLinklayer struct {