aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/syscall_linux.go
diff options
context:
space:
mode:
authorLuca Bruno <luca.bruno@coreos.com>2017-06-15 11:35:43 +0000
committerIan Lance Taylor <iant@golang.org>2017-08-29 23:30:21 +0000
commit93da0b6e66f24c4c307e0df37ceb102a33306174 (patch)
tree9e7a2337639f230ed4650abcdeeb4eea655f6dc7 /src/syscall/syscall_linux.go
parent5a7283f1467014fb1f5e149b76f61e0a3138accf (diff)
downloadgo-93da0b6e66f24c4c307e0df37ceb102a33306174.tar.xz
syscall: drop dummy byte for oob in unixgram SendmsgN
This commit relaxes SendmsgN behavior of introducing a dummy 1-byte payload when sending ancillary-only messages. The fake payload is not needed for SOCK_DGRAM type sockets, and actually breaks interoperability with other fd-passing software (journald is one known example). This introduces an additional check to avoid injecting dummy payload in such case. Full reference at https:/golang.org/issue/6476#issue-51285243 Fixes #6476 Change-Id: I19a974b4e7920e002bd0556259ab766572358520 Reviewed-on: https://go-review.googlesource.com/45872 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/syscall/syscall_linux.go')
-rw-r--r--src/syscall/syscall_linux.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go
index 4d5a5e12d3..3c7d378d71 100644
--- a/src/syscall/syscall_linux.go
+++ b/src/syscall/syscall_linux.go
@@ -537,8 +537,13 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from
}
var dummy byte
if len(oob) > 0 {
+ var sockType int
+ sockType, err = GetsockoptInt(fd, SOL_SOCKET, SO_TYPE)
+ if err != nil {
+ return
+ }
// receive at least one normal byte
- if len(p) == 0 {
+ if sockType != SOCK_DGRAM && len(p) == 0 {
iov.Base = &dummy
iov.SetLen(1)
}
@@ -584,8 +589,13 @@ func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error)
}
var dummy byte
if len(oob) > 0 {
+ var sockType int
+ sockType, err = GetsockoptInt(fd, SOL_SOCKET, SO_TYPE)
+ if err != nil {
+ return 0, err
+ }
// send at least one normal byte
- if len(p) == 0 {
+ if sockType != SOCK_DGRAM && len(p) == 0 {
iov.Base = &dummy
iov.SetLen(1)
}