dns: add length check to avoid panic

This commit is contained in:
nadoo committed 2020-05-05 01:30:57 +08:00
1 parent 665d722d2c
commit e3c57ba369
6 files changed
+20 -55

No files matched your search

+4
View File
@@ -403,6 +403,10 @@ func MarshalDomainTo(w io.Writer, domain string) (int, error) {
// UnmarshalDomain gets domain from bytes.
func (m *Message) UnmarshalDomain(b []byte) (string, int, error) {
if len(b) < 2 {
return "", 0, errors.New("UnmarshalDomain: not enough size")
}
var idx, size int
var labels = []string{}