This patch to libgo fixes the handling of Unix domain @ addresses, a GNU/Linux feature. The library was computing the length incorrectly. I actually fixed this in the master library in January 2011, but somehow failed to propagate the fix into the gccgo library. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch.
Ian
diff -r 8ddfd13a6bc8 libgo/go/syscall/socket.go --- a/libgo/go/syscall/socket.go Tue Nov 20 22:38:30 2012 -0800 +++ b/libgo/go/syscall/socket.go Sat Nov 24 12:19:05 2012 -0800 @@ -87,12 +87,16 @@ 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 -r 8ddfd13a6bc8 libgo/go/syscall/socket_linux.go --- a/libgo/go/syscall/socket_linux.go Tue Nov 20 22:38:30 2012 -0800 +++ b/libgo/go/syscall/socket_linux.go Sat Nov 24 12:19:05 2012 -0800 @@ -103,7 +103,7 @@ // 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++ }