Commit 2b6fb578 authored by Andrey Meshkov's avatar Andrey Meshkov Committed by Miek Gieben

DoH: Fixing panic in case if there's no response (#2577)

* Fixing panic in case if there's no response

There could be a situation when there's no response after ServeDNS call. With the current implementation, this leads to panic.

* Add comment
parent 47cce40d
...@@ -119,6 +119,14 @@ func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -119,6 +119,14 @@ func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// We should expect a packet to be returned that we can send to the client. // We should expect a packet to be returned that we can send to the client.
s.ServeDNS(context.Background(), dw, msg) s.ServeDNS(context.Background(), dw, msg)
// See section 4.2.1 of RFC 8484.
// We are using code 500 to indicate an unexpected situation when the chain
// handler has not provided any response message.
if dw.Msg == nil {
http.Error(w, "No response", http.StatusInternalServerError)
return
}
buf, _ := dw.Msg.Pack() buf, _ := dw.Msg.Pack()
mt, _ := response.Typify(dw.Msg, time.Now().UTC()) mt, _ := response.Typify(dw.Msg, time.Now().UTC())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment