core: harden request.Request (#1009)

Check for a nil message and if we have a question section. Request is
usually called with an external Msg that already saw validation checks,
but we may also call it from message we create of our own, that may or
may not adhire to this. Just be more robust in this case.

This PR reverts a previous commit that was applied to master.
This commit is contained in:
Miek Gieben
2017-08-31 16:24:11 +02:00
committed by GitHub
parent c72084187c
commit 5eccfa2d1e
3 changed files with 98 additions and 13 deletions

View File

@@ -289,12 +289,6 @@ 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())