Repository navigation
Read RFC 3597 generic RDATA of known types as their records - #196
Merged
Merged
Conversation
RFC 3597 section 5 has an RR of a known type in the generic form, \# and the length and hex of its RDATA, be treated as a known type. The zone reader kept the octets of every type, so A \# 4 C0000201 read as <<192,0,2,1>>, and took octets that are no RDATA of their type at all. The octets of a type the reader knows are now read as its record by the wire decoder, with no message for a compression pointer to point into, and octets it cannot read as a record of the type are refused, as BIND refuses them. Other types keep their octets. Names come as the wire decoder gives them, without a final dot. What the zone writer writes in the generic form, such as a DS without a digest, reads back as the record it wrote. dns_decode:decode_rrdata/4 is exported for the reader, its message typed binary(), as RDATA outside a message has none. Five tests used TYPE99 as unassigned, but it is SPF; they use TYPE65280 now.
The wire decoder reads an A, AAAA, EUI48, EUI64 or DHCID only in class IN, and the zone reader gives it the record's class. A CH A in the generic form is refused as no RDATA of its type; read as class IN, it would be refused later, as an A that does not fit its class, and no test told the two apart.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC 3597 §5 lets a zone write the RDATA of any type in the generic form,
\# <length> <hex>, and has an RR of a known type in that form be treated as that type: "all further processing by the server MUST treat it as a known type". The zone reader kept the octets of every type, soA \# 4 C0000201read as<<192,0,2,1>>whereA 192.0.2.1reads as#dns_rrdata_a{}, and took octets that are no RDATA of their type at all.The octets of a type the reader knows are now read as its record, by the wire decoder,
dns_decode:decode_rrdata/4, with no message for a compression pointer to point into. Octets the decoder cannot read as a record of the type are refused. Against BIND 9.20.30'snamed-checkzone:A \# 4 C0000201,TYPE1 \# 4 C0000201A 192.0.2.1<<192,0,2,1>>#dns_rrdata_a{ip = {192,0,2,1}}MX \# 7 000A0378797A00MX 10 xyz.#dns_rrdata_mx{preference = 10, exchange = <<"xyz">>}TXT \# 3 026869TXT "hi"#dns_rrdata_txt{txt = [<<"hi">>]}A \# 3 C00002,A \# 5 C000020100MX \# 4 000AC000, a compression pointerMX \# 4 000A0178,NS \# 4 036E7332, no root labelTXT \# 0TYPE65280 \# 2 ABCD,NULL \# 2 ABCD<<16#AB,16#CD>><<16#AB,16#CD>>The refusal is
{semantic_error, rfc3597_not_rdata_of_type}. Names in such RDATA come as the wire decoder gives them, without a final dot (xyz), where the presentation form givesxyz.; dns_erlang takes both as the same name. What the wire decoder takes, the generic form takes too, so an HTTPS record whose mandatory names a key twice, which the presentation form refuses, reads from its generic form, as it decodes from the wire.The zone writer writes in the generic form what the presentation form cannot hold, such as a DS without a digest, and that now reads back as the record it wrote, where it read back as octets.
dns_decode:decode_rrdata/4, exported for tests only, is exported for the reader now, its message typedbinary(), as RDATA outside a message has none.dns_decodeis not documented.Tests:
parse_generic_rdata_of_known_typeshas BIND's readings and refusals above, and reads each of the 106 dnspython wire samples ofdata_samples:rrdata_wire/0in the generic form as the wire decoder reads it, a record wherever it reads one; and the writer's DS without a digest reads back as that DS.parse_uncommon_type_numbersgave 20 known types the octetsC0000201, which are no RDATA of most of them, and gives each a dnspython sample of its type now. Five tests usedTYPE99as an unassigned type, but 99 is SPF, which the reader reads; they useTYPE65280, of the private use range, now. Not decoding, decoding with pointers, keeping octets the decoder could not read, or letting its errors through makes a test fail.