Closed
Description
The following two newly created test cases fail:
func TestMsgCompressMINFO(t *testing.T) {
msg := new(Msg)
msg.Compress = true
msg.SetQuestion("www.example.com.", TypeSRV)
msg.Answer = append(msg.Answer, &MINFO{
Hdr: RR_Header{Name: "www.example.com.", Class: 1, Rrtype: TypeSRV, Ttl: 0x3c},
Rmail: "mail.example.org.",
Email: "mail.example.org.",
})
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))
}
}
func TestMsgCompressSOA(t *testing.T) {
msg := new(Msg)
msg.Compress = true
msg.SetQuestion("www.example.com.", TypeSRV)
msg.Answer = append(msg.Answer, &SOA{
Hdr: RR_Header{Name: "www.example.com.", Class: 1, Rrtype: TypeSRV, Ttl: 0x3c},
Ns: "ns.example.org.",
Mbox: "mail.example.org.",
})
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: TestMsgCompressMINFO (0.00s)
length_test.go:402: predicted compressed length is wrong: predicted 81, actual 65
--- FAIL: TestMsgCompressSOA (0.00s)
length_test.go:422: predicted compressed length is wrong: predicted 99, actual 88
I believe the compressedLen
code isn't handling matches between the two compressed domains properly, whereas the PackDomainName
code is.
/cc @miekg
Metadata
Metadata
Assignees
Labels
No labels