unix: 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 golang/go#63579.

Change-Id: I2f26de4bcf614c4635ad188b1afa3d14ebd9a95f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/535955
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
F Y
2023-10-23 09:05:11 +00:00
committed by Gopher Robot
parent 1bfbee0e20
commit 1e638101df
5 changed files with 19 additions and 5 deletions
+11 -1
View File
@@ -517,7 +517,7 @@ func TestSockaddrUnix_sockaddr(t *testing.T) {
slen: 2, // family (uint16)
},
{
name: "abstract",
name: "abstract_starting_with_at",
sa: &SockaddrUnix{
Name: "@",
},
@@ -526,6 +526,16 @@ func TestSockaddrUnix_sockaddr(t *testing.T) {
},
slen: 3, // family (uint16) + NULL
},
{
name: "abstract_starting_with_null",
sa: &SockaddrUnix{
Name: "\x00",
},
raw: &RawSockaddrUnix{
Family: AF_UNIX,
},
slen: 3, // family (uint16) + NULL
},
{
name: "named",
sa: &SockaddrUnix{