Skip to content

Correct value of DNS_NAME_MAXLABELS

Tony Finch requested to merge 3998-incorrect-maxlabels into main

It should be floor(DNS_NAME_MAXWIRE / 2) + 1 == 128

The mistake was introduced in c6bf5149 because:

  • I was refactoring an existing DNS_MAX_LABELS defined as 127

  • There was a longstanding bug in dns_name_isvalid() which checked the number of labels against 127U instead of 128

  • I mistakenly thought dns_name_isvalid() was correct and dns_name_countlabels() was incorrect, but the reverse was true.

After this commit, occurrances of DNS_NAME_MAXLABELS with value 128 are consistent with the use of 127 or 128 before commit c6bf5149 except for the mistake in dns_name_isvalid(). This commit adds a test case that checks the MAXLABELS case in dns_name_fromtext() and dns_name_isvalid().

Closes #3998 (closed)

Merge request reports