dns: check length in UnmarshalDomain to avoid panic

This commit is contained in:
nadoo committed 2020-08-21 23:54:18 +08:00
1 parent a118ec5837
commit a42d3a68d0
6 files changed
+18 -11

No files matched your search

+2 -2
View File
@@ -14,7 +14,7 @@ import (
)
// HandleFunc function handles the dns TypeA or TypeAAAA answer.
type HandleFunc func(Domain, ip string) error
type HandleFunc func(domain, ip string) error
// Config for dns.
type Config struct {
@@ -55,7 +55,7 @@ func NewClient(proxy proxy.Proxy, config *Config) (*Client, error) {
}
// Exchange handles request message and returns response message.
// reqBytes = reqLen + reqMsg
// NOTE: reqBytes = reqLen + reqMsg.
func (c *Client) Exchange(reqBytes []byte, clientAddr string, preferTCP bool) ([]byte, error) {
req, err := UnmarshalMessage(reqBytes[2:])
if err != nil {