]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
conn: set unused OOB to zero length
authorJason A. Donenfeld <Jason@zx2c4.com>
Sat, 21 Oct 2023 17:32:07 +0000 (19:32 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Sat, 21 Oct 2023 17:32:07 +0000 (19:32 +0200)
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>
conn/bind_std.go

index e1bcbd13202091d911aaaa3d4fff117adf25f0ac..46df7fd4ef61ebb3cd892b87d008a63fa7ae3471 100644 (file)
@@ -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)