Skip to content

Commit

Permalink
Add unit test to verify invalid label pointer is handled
Browse files Browse the repository at this point in the history
  • Loading branch information
jtt committed Feb 9, 2022
1 parent d2979cf commit 792350b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dnsutils/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,14 @@ func TestDecodeDnsQuestion_QtypeMissing(t *testing.T) {
}
}

func TestDecodeQuestion_InvalidPointer(t *testing.T) {
decoded := []byte{88, 27, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 202}
_, _, _, err := DecodeQuestion(decoded)
if !errors.Is(err, ErrDecodeDnsLabelTooShort) {
t.Errorf("bad error returned: %v", err)
}
}

func TestDecodeDnsAnswer_PacketTooShort(t *testing.T) {
payload := []byte{46, 172, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 15, 100, 110, 115, 116, 97, 112, 99, 111, 108, 108, 101, 99, 116,
111, 114, 4, 116, 101, 115, 116, 0, 0, 1, 0, 1, 15, 100, 110, 115, 116, 97, 112, 99, 111, 108, 108, 101, 99, 116,
Expand Down

0 comments on commit 792350b

Please sign in to comment.