From: Alexander Goussas Date: Mon, 2 Feb 2026 03:46:45 +0000 (-0500) Subject: fix: handle empty NAME in first question X-Git-Url: http://git.frustrated-labs.net/?a=commitdiff_plain;h=be96f1faf17bb0ee6075608eef12113517faabac;p=dns-phrasex.git fix: handle empty NAME in first question --- 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( <>,