DNS: prevent panic from rejecting invalid domain

This commit is contained in:
风扇滑翔翼 2025-07-16 14:51:45 +00:00 committed by GitHub
parent cb1afb33e6
commit d72ce8ee91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -338,11 +338,16 @@ func (h *Handler) rejectNonIPQuery(id uint16, qType dnsmessage.Type, domain stri
})
builder.EnableCompression()
common.Must(builder.StartQuestions())
common.Must(builder.Question(dnsmessage.Question{
err := builder.Question(dnsmessage.Question{
Name: dnsmessage.MustNewName(domain),
Class: dnsmessage.ClassINET,
Type: qType,
}))
})
if err != nil {
errors.LogInfo(context.Background(), "unexpected domain ", domain, " when building reject message: ", err)
b.Release()
return
}
msgBytes, err := builder.Finish()
if err != nil {