phuslu / fastdns

Fastest DNS package for Go
MIT License
186 stars 12 forks source link

decode name panic #2

Closed femtoeu closed 1 year ago

femtoeu commented 1 year ago

panic: runtime error: index out of range [201] with length 9

goroutine 852 [running]: github.com/phuslu/fastdns.(*Message).DecodeName(0xc00f291260, {0x0?, 0x0, 0x7a4a58?}, {0xc0037f352b, 0x9, 0x5cc46c?}) /root/go/pkg/mod/github.com/phuslu/fastdns@v0.8.1/message.go:201 +0x431

    req, resp := fastdns.AcquireMessage(), fastdns.AcquireMessage()
    defer fastdns.ReleaseMessage(req)
    defer fastdns.ReleaseMessage(resp)

    req.SetRequestQustion(domain, fastdns.TypeMX, fastdns.ClassINET)

    err := fastdnsClient.Exchange(req, resp)
    if err != nil {
        log.Println(err)
        return "", "", err
    }

    var hosts []string
    _ = resp.Walk(func(name []byte, typ fastdns.Type, class fastdns.Class, ttl uint32, data []byte) bool {
        if typ == fastdns.TypeMX {
            hosts = append(hosts, string(resp.DecodeName(nil, data[2:])))
        }

        return true
    })
phuslu commented 1 year ago

Could you please give me the domain of MX, if confidential, can mailto me.

femtoeu commented 1 year ago

i cannot reproduce it with same domain. I think this is a DNS server issue