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 := &SOA{Hdr: RR_Header{Name: ".", Rrtype: TypeSOA, Class: ClassINET, Ttl: 12345},
|
||||
Ns: ".",
|
||||
|
@ -329,7 +329,7 @@ func testMsgLengthCompressionMalformed(t *testing.T) {
|
|||
m := new(Msg)
|
||||
m.Compress = true
|
||||
m.Ns = []RR{soa}
|
||||
m.Len()
|
||||
m.Len() // Should not crash.
|
||||
}
|
||||
|
||||
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) {
|
||||
off := 0
|
||||
end := false
|
||||
if s == "" { // don't bork on bogus data
|
||||
return 0, false
|
||||
}
|
||||
for {
|
||||
if _, ok := c[s[off:]]; ok {
|
||||
return len(s[off:]), true
|
||||
|
|
Loading…
Reference in New Issue