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

+4
View File
@@ -415,6 +415,10 @@ func (m *Message) UnmarshalDomain(b []byte) (string, int, error) {
break
} else if b[idx]&0xC0 == 0xC0 {
if len(b[idx:]) < 2 {
return "", 0, errors.New("UnmarshalDomain: not enough size for compressed domain")
}
offset := binary.BigEndian.Uint16(b[idx : idx+2])
label, err := m.UnmarshalDomainPoint(int(offset & 0x3FFF))
if err != nil {