mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 05:39:57 +00:00
TUN-9467: bump coredns to solve CVE
* TUN-9467: bump coredns to solve CVE
This commit is contained in:

committed by
João "Pisco" Fernandes

parent
f8d12c9d39
commit
a408612f26
20
vendor/github.com/miekg/dns/server.go
generated
vendored
20
vendor/github.com/miekg/dns/server.go
generated
vendored
@@ -188,6 +188,14 @@ type DecorateReader func(Reader) Reader
|
||||
// Implementations should never return a nil Writer.
|
||||
type DecorateWriter func(Writer) Writer
|
||||
|
||||
// MsgInvalidFunc is a listener hook for observing incoming messages that were discarded
|
||||
// because they could not be parsed.
|
||||
// Every message that is read by a Reader will eventually be provided to the Handler,
|
||||
// rejected (or ignored) by the MsgAcceptFunc, or passed to this function.
|
||||
type MsgInvalidFunc func(m []byte, err error)
|
||||
|
||||
func DefaultMsgInvalidFunc(m []byte, err error) {}
|
||||
|
||||
// A Server defines parameters for running an DNS server.
|
||||
type Server struct {
|
||||
// Address to listen on, ":dns" if empty.
|
||||
@@ -218,6 +226,7 @@ type Server struct {
|
||||
// If NotifyStartedFunc is set it is called once the server has started listening.
|
||||
NotifyStartedFunc func()
|
||||
// DecorateReader is optional, allows customization of the process that reads raw DNS messages.
|
||||
// The decorated reader must not mutate the data read from the conn.
|
||||
DecorateReader DecorateReader
|
||||
// DecorateWriter is optional, allows customization of the process that writes raw DNS messages.
|
||||
DecorateWriter DecorateWriter
|
||||
@@ -233,6 +242,8 @@ type Server struct {
|
||||
// AcceptMsgFunc will check the incoming message and will reject it early in the process.
|
||||
// By default DefaultMsgAcceptFunc will be used.
|
||||
MsgAcceptFunc MsgAcceptFunc
|
||||
// MsgInvalidFunc is optional, will be called if a message is received but cannot be parsed.
|
||||
MsgInvalidFunc MsgInvalidFunc
|
||||
|
||||
// Shutdown handling
|
||||
lock sync.RWMutex
|
||||
@@ -277,6 +288,9 @@ func (srv *Server) init() {
|
||||
if srv.MsgAcceptFunc == nil {
|
||||
srv.MsgAcceptFunc = DefaultMsgAcceptFunc
|
||||
}
|
||||
if srv.MsgInvalidFunc == nil {
|
||||
srv.MsgInvalidFunc = DefaultMsgInvalidFunc
|
||||
}
|
||||
if srv.Handler == nil {
|
||||
srv.Handler = DefaultServeMux
|
||||
}
|
||||
@@ -531,6 +545,7 @@ func (srv *Server) serveUDP(l net.PacketConn) error {
|
||||
if cap(m) == srv.UDPSize {
|
||||
srv.udpPool.Put(m[:srv.UDPSize])
|
||||
}
|
||||
srv.MsgInvalidFunc(m, ErrShortRead)
|
||||
continue
|
||||
}
|
||||
wg.Add(1)
|
||||
@@ -611,6 +626,7 @@ func (srv *Server) serveUDPPacket(wg *sync.WaitGroup, m []byte, u net.PacketConn
|
||||
func (srv *Server) serveDNS(m []byte, w *response) {
|
||||
dh, off, err := unpackMsgHdr(m, 0)
|
||||
if err != nil {
|
||||
srv.MsgInvalidFunc(m, err)
|
||||
// Let client hang, they are sending crap; any reply can be used to amplify.
|
||||
return
|
||||
}
|
||||
@@ -620,10 +636,12 @@ func (srv *Server) serveDNS(m []byte, w *response) {
|
||||
|
||||
switch action := srv.MsgAcceptFunc(dh); action {
|
||||
case MsgAccept:
|
||||
if req.unpack(dh, m, off) == nil {
|
||||
err := req.unpack(dh, m, off)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
|
||||
srv.MsgInvalidFunc(m, err)
|
||||
fallthrough
|
||||
case MsgReject, MsgRejectNotImplemented:
|
||||
opcode := req.Opcode
|
||||
|
Reference in New Issue
Block a user