From a90be440212d0ff450b66ce871c8b725fbc60f7c Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 28 Jul 2022 11:42:45 +0200 Subject: [PATCH] unix: fix sendmsgN return value for empty iovecs and non-empty oob Don't shadow the empty var when determining whether to send a single byte when iovecs are empty but oob is non-empty. This will lead to the n value correctly being reset to 0 before return. No test because it's not possible to trigger this case on all platforms, e.g. darwin where sendmsg with empty buf and non-empty oob returns EINVAL. This was introduced by CL 412497 and CL 419396. Updates golang/go#52885 Change-Id: Iafc5a4b22e10b396ba5f7d4f2ac1c50df195a125 Reviewed-on: https://go-review.googlesource.com/c/sys/+/419914 Auto-Submit: Tobias Klauser Reviewed-by: Ian Lance Taylor Run-TryBot: Tobias Klauser Reviewed-by: Florian Lehner TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui --- unix/syscall_aix.go | 2 +- unix/syscall_bsd.go | 2 +- unix/syscall_linux.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/unix/syscall_aix.go b/unix/syscall_aix.go index e2a30e88..2db1b51e 100644 --- a/unix/syscall_aix.go +++ b/unix/syscall_aix.go @@ -253,7 +253,7 @@ func sendmsgN(fd int, iov []Iovec, oob []byte, ptr unsafe.Pointer, salen _Sockle var empty bool if len(oob) > 0 { // send at least one normal byte - empty := emptyIovecs(iov) + empty = emptyIovecs(iov) if empty { var iova [1]Iovec iova[0].Base = &dummy diff --git a/unix/syscall_bsd.go b/unix/syscall_bsd.go index c437fc5d..eda42671 100644 --- a/unix/syscall_bsd.go +++ b/unix/syscall_bsd.go @@ -363,7 +363,7 @@ func sendmsgN(fd int, iov []Iovec, oob []byte, ptr unsafe.Pointer, salen _Sockle var empty bool if len(oob) > 0 { // send at least one normal byte - empty := emptyIovecs(iov) + empty = emptyIovecs(iov) if empty { var iova [1]Iovec iova[0].Base = &dummy diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index 5e4a94f7..ecb0f27f 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -1541,7 +1541,7 @@ func sendmsgN(fd int, iov []Iovec, oob []byte, ptr unsafe.Pointer, salen _Sockle var dummy byte var empty bool if len(oob) > 0 { - empty := emptyIovecs(iov) + empty = emptyIovecs(iov) if empty { var sockType int sockType, err = GetsockoptInt(fd, SOL_SOCKET, SO_TYPE)