From be96f1faf17bb0ee6075608eef12113517faabac Mon Sep 17 00:00:00 2001 From: Alexander Goussas Date: Sun, 1 Feb 2026 22:46:45 -0500 Subject: [PATCH] fix: handle empty NAME in first question --- lib/dns_phrases/message/parser.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/dns_phrases/message/parser.ex b/lib/dns_phrases/message/parser.ex index f2ad615..cd3dab9 100644 --- a/lib/dns_phrases/message/parser.ex +++ b/lib/dns_phrases/message/parser.ex @@ -44,6 +44,16 @@ defmodule DnsPhrases.Message.Parser do def parse_question(data), do: parse_question(data, []) @spec parse_question(bitstring, list) :: {list(), integer(), integer()} + + # This one executes on an NS record with zero-length NAME in the first question. + defp parse_question( + <<0::8, type::integer-size(16), class::integer-size(16), _rest::bitstring>>, + parts + ) do + {parts, type, class} + end + + # This one executes for non zero-length NAME defp parse_question( <>, -- 2.43.0