mirror of
https://github.com/miekg/dns.git
synced 2025-10-17 21:01:00 +02:00
parent
9f5fcf8459
commit
34f5a12bfc
@ -316,7 +316,7 @@ func TestMsgLength2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testMsgLengthCompressionMalformed(t *testing.T) {
|
func TestMsgLengthCompressionMalformed(t *testing.T) {
|
||||||
// SOA with empty hostmaster, which is illegal
|
// SOA with empty hostmaster, which is illegal
|
||||||
soa := &SOA{Hdr: RR_Header{Name: ".", Rrtype: TypeSOA, Class: ClassINET, Ttl: 12345},
|
soa := &SOA{Hdr: RR_Header{Name: ".", Rrtype: TypeSOA, Class: ClassINET, Ttl: 12345},
|
||||||
Ns: ".",
|
Ns: ".",
|
||||||
@ -329,7 +329,7 @@ func testMsgLengthCompressionMalformed(t *testing.T) {
|
|||||||
m := new(Msg)
|
m := new(Msg)
|
||||||
m.Compress = true
|
m.Compress = true
|
||||||
m.Ns = []RR{soa}
|
m.Ns = []RR{soa}
|
||||||
m.Len()
|
m.Len() // Should not crash.
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkMsgLength(b *testing.B) {
|
func BenchmarkMsgLength(b *testing.B) {
|
||||||
|
3
msg.go
3
msg.go
@ -1702,6 +1702,9 @@ func compressionLenHelper(c map[string]int, s string) {
|
|||||||
func compressionLenSearch(c map[string]int, s string) (int, bool) {
|
func compressionLenSearch(c map[string]int, s string) (int, bool) {
|
||||||
off := 0
|
off := 0
|
||||||
end := false
|
end := false
|
||||||
|
if s == "" { // don't bork on bogus data
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
for {
|
for {
|
||||||
if _, ok := c[s[off:]]; ok {
|
if _, ok := c[s[off:]]; ok {
|
||||||
return len(s[off:]), true
|
return len(s[off:]), true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user