Skip to content

Commit 3de6033

Browse files
F Ygopherbot
F Y
authored andcommitted
syscall: stop counting trailing NUL for abstract addresses starting with NUL
Changes trailing-NUL-counting behavior for abstract addresses starting with the NUL character to be the same as abstract addresses starting with the @ character. For #63579. Change-Id: I206e4d0d808396998cb7d92a9e26dda854cb1248 GitHub-Last-Rev: 0ff0a9c GitHub-Pull-Request: #63580 Reviewed-on: https://go-review.googlesource.com/c/go/+/535776 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent c75a617 commit 3de6033

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/syscall/syscall_linux.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
554554
if n > 0 {
555555
sl += _Socklen(n) + 1
556556
}
557-
if sa.raw.Path[0] == '@' {
557+
if sa.raw.Path[0] == '@' || (sa.raw.Path[0] == 0 && sl > 3) {
558+
// Check sl > 3 so we don't change unnamed socket behavior.
558559
sa.raw.Path[0] = 0
559560
// Don't count trailing NUL for abstract address.
560561
sl--

src/syscall/syscall_solaris.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
131131
if n > 0 {
132132
sl += _Socklen(n) + 1
133133
}
134-
if sa.raw.Path[0] == '@' {
134+
if sa.raw.Path[0] == '@' || (sa.raw.Path[0] == 0 && sl > 3) {
135+
// Check sl > 3 so we don't change unnamed socket behavior.
135136
sa.raw.Path[0] = 0
136137
// Don't count trailing NUL for abstract address.
137138
sl--

src/syscall/syscall_windows.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,8 @@ func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, int32, error) {
862862
if n > 0 {
863863
sl += int32(n) + 1
864864
}
865-
if sa.raw.Path[0] == '@' {
865+
if sa.raw.Path[0] == '@' || (sa.raw.Path[0] == 0 && sl > 3) {
866+
// Check sl > 3 so we don't change unnamed socket behavior.
866867
sa.raw.Path[0] = 0
867868
// Don't count trailing NUL for abstract address.
868869
sl--

0 commit comments

Comments
 (0)