diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2023-10-21 19:32:07 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2023-10-21 19:32:07 +0200 |
commit | b3df23dcd40ba4568572f338f9fd16b87053fc29 (patch) | |
tree | 4495bae6a9035944aa74f9ee441cb4d5e3309982 /conn/bind_std.go | |
parent | f502ec3fad116d11109529bcf283e464f4822c18 (diff) |
conn: set unused OOB to zero length
Otherwise in the event that we're using GSO without sticky sockets, we
pass garbage OOB buffers to sendmmsg, making a EINVAL, when GSO doesn't
set its header.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'conn/bind_std.go')
-rw-r--r-- | conn/bind_std.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/conn/bind_std.go b/conn/bind_std.go index e1bcbd1..46df7fd 100644 --- a/conn/bind_std.go +++ b/conn/bind_std.go @@ -65,7 +65,7 @@ func NewStdNetBind() Bind { msgs := make([]ipv6.Message, IdealBatchSize) for i := range msgs { msgs[i].Buffers = make(net.Buffers, 1) - msgs[i].OOB = make([]byte, stickyControlSize+gsoControlSize) + msgs[i].OOB = make([]byte, 0, stickyControlSize+gsoControlSize) } return &msgs }, @@ -200,6 +200,7 @@ again: func (s *StdNetBind) putMessages(msgs *[]ipv6.Message) { for i := range *msgs { + (*msgs)[i].OOB = (*msgs)[i].OOB[:0] (*msgs)[i] = ipv6.Message{Buffers: (*msgs)[i].Buffers, OOB: (*msgs)[i].OOB} } s.msgsPool.Put(msgs) |