miekg / dns

DNS library in Go
https://miek.nl/2014/august/16/go-dns-package
BSD 3-Clause "New" or "Revised" License
7.95k stars 1.13k forks source link

TXT records of length more than 255 characters. #1428

Closed matheswaran99 closed 1 year ago

matheswaran99 commented 1 year ago

In some cases the TXT record might have more than 255 characters. But dns does not support with more than 255 characters. And also getting error like "dns: string exceeded 255 bytes in txt".

gibson042 commented 1 year ago

The content of a TXT record is a sequence of \s, each of which is itself limited to maximum content length of 255 characters (and it isn't even possible to attempt expressing a longer one on the wire).

RFC 1035 section 3.3.14

    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    /                   TXT-DATA                    /
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

where:

TXT-DATA        One or more <character-string>s.

TXT RRs are used to hold descriptive text. The semantics of the text depends on the domain where it is found.

RFC 1035 section 3.3

\ is a single length octet followed by that number of characters. \ is treated as binary information, and can be up to 256 characters in length (including the length octet).

Some higher-level protocols such as SPF interpret a TXT record containing multiple \s by concatenating those strings and treating them as a single longer string (cf. RFC 7208 section 3.3), but that is not inherent to the DNS, which must therefore preserve each individual element of the sequence.

tmthrgd commented 1 year ago

As mentioned above, this is unfortunately a limitation in DNS itself and how to address it is protocol specific. Closing.