Closed
Description
The following new test case fails:
func TestMsgCompressionMultipleQuestions(t *testing.T) {
msg := new(Msg)
msg.Compress = true
msg.SetQuestion("www.example.org.", TypeA)
msg.Question = append(msg.Question, Question{"other.example.org.", TypeA, ClassINET})
predicted := msg.Len()
buf, err := msg.Pack()
if err != nil {
t.Error(err)
}
if predicted != len(buf) {
t.Fatalf("predicted compressed length is wrong: predicted %d, actual %d", predicted, len(buf))
}
}
with:
--- FAIL: TestMsgCompressionMultipleQuestions (0.00s)
length_test.go:387: predicted compressed length is wrong: predicted 56, actual 45
This fails because compressedLen
doesn't compress any names in dns.Question
:
Lines 909 to 912 in 1c9c9bf
but the packing code does compress names in Question
:
Lines 1093 to 1094 in 1c9c9bf
Line 750 in 1c9c9bf
Although I know that multiple questions are very rare and largely unsupported, this is still a bug. It's very easy to fix, but I just don't know what the correct behaviour is here.
Can QNAMEs be compressed and if so, do we actually want to compress them? I can't seem to find an answer in the RFCs, but I suspect we do want to skip compressing them either way.
/cc @miekg
Metadata
Metadata
Assignees
Labels
No labels