core: add nil check (#1005)

Check if msg is nil in DefaultErrorFunc. If this is the case log this
and short cut the function.

Hoping to get more insight in #925
This commit is contained in:
Miek Gieben
2017-08-31 08:20:13 +02:00
committed by GitHub
parent 3974071f48
commit c72084187c

View File

@@ -289,6 +289,12 @@ func DefaultErrorFunc(w dns.ResponseWriter, r *dns.Msg, rc int) {
answer := new(dns.Msg)
answer.SetRcode(r, rc)
if r == nil {
log.Printf("[WARNING] DefaultErrorFunc called with nil *dns.Msg (Remote: %s)", w.RemoteAddr().String())
w.WriteMsg(answer)
return
}
state.SizeAndDo(answer)
vars.Report(state, vars.Dropped, rcode.ToString(rc), answer.Len(), time.Now())