From abe9b708f07e047953964065131f8d0a900cd826 Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Mon, 5 Feb 2018 17:04:05 -0600 Subject: [PATCH] Patch dns vendor code for picking up a TCP DOS attack bugfix --- vendor/github.com/miekg/dns/server.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/vendor/github.com/miekg/dns/server.go b/vendor/github.com/miekg/dns/server.go index 0ca6e008c08b..e18068e2f2b0 100644 --- a/vendor/github.com/miekg/dns/server.go +++ b/vendor/github.com/miekg/dns/server.go @@ -477,13 +477,6 @@ func (srv *Server) serveTCP(l net.Listener) error { // deadline is not used here for { rw, err := l.Accept() - if err != nil { - if neterr, ok := err.(net.Error); ok && neterr.Temporary() { - continue - } - return err - } - m, err := reader.ReadTCP(rw, rtimeout) srv.lock.RLock() if !srv.started { srv.lock.RUnlock() @@ -491,10 +484,20 @@ func (srv *Server) serveTCP(l net.Listener) error { } srv.lock.RUnlock() if err != nil { - continue + if neterr, ok := err.(net.Error); ok && neterr.Temporary() { + continue + } + return err } - srv.inFlight.Add(1) - go srv.serve(rw.RemoteAddr(), handler, m, nil, nil, rw) + go func() { + m, err := reader.ReadTCP(rw, rtimeout) + if err != nil { + rw.Close() + return + } + srv.serve(rw.RemoteAddr(), handler, m, nil, nil, rw) + }() + } }