From d2979cfb4f2357895458bebce5ac3248bbbfa2b9 Mon Sep 17 00:00:00 2001 From: Jukka Taimisto Date: Wed, 9 Feb 2022 11:05:10 +0200 Subject: [PATCH] Add length check before reading label pointer --- dnsutils/dns.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dnsutils/dns.go b/dnsutils/dns.go index 7ba72060..b15f9e5f 100644 --- a/dnsutils/dns.go +++ b/dnsutils/dns.go @@ -342,6 +342,9 @@ func _ParseLabels(offset int, payload []byte, pointers map[uint16]int) (string, } // label pointer support ? if length>>6 == 3 { + if offset+1 >= len(payload) { + return "", 0, ErrDecodeDnsLabelTooShort + } ptr := binary.BigEndian.Uint16(payload[offset:offset+2]) & 16383 _, exist := pointers[ptr] if exist {