[GH-ISSUE #314] failure to parse a valid zone file #440

Closed
opened 2026-03-15 22:29:48 +03:00 by kerem · 9 comments
Owner

Originally created by @little-dude on GitHub (Dec 14, 2017).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/314

I'm taking a look at deckard as suggested in https://github.com/bluejekyll/trust-dns/issues/219, and the server tests are failing because trust-dns fails to parse this zone file:

$ORIGIN example.com.
$TTL 3600

@	SOA	dns1.example.com. hostmaster.example.com. (
		2010111213	; serial
		6h		; refresh
		1h		; retry
		1w		; expire
		1d )		; minimum

	NS	dns1
	NS	dns2
	MX	10 mail

dns1	A	192.0.2.1
	AAAA	2001:DB8::1

dns2	A	192.0.2.2
	AAAA	2001:DB8::2

mail	A	192.0.2.3
	AAAA	2001:DB8::3

There are two issues:

  • the parser does not support the specifiying times with letters such as 6h, 2w or 1d.
  • the parser does not support implicit record class, you have to explicitely set it to IN
Originally created by @little-dude on GitHub (Dec 14, 2017). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/314 I'm taking a look at deckard as suggested in https://github.com/bluejekyll/trust-dns/issues/219, and the server tests are failing because trust-dns fails to parse this zone file: ``` $ORIGIN example.com. $TTL 3600 @ SOA dns1.example.com. hostmaster.example.com. ( 2010111213 ; serial 6h ; refresh 1h ; retry 1w ; expire 1d ) ; minimum NS dns1 NS dns2 MX 10 mail dns1 A 192.0.2.1 AAAA 2001:DB8::1 dns2 A 192.0.2.2 AAAA 2001:DB8::2 mail A 192.0.2.3 AAAA 2001:DB8::3 ``` There are two issues: - the parser does not support the specifiying times with letters such as `6h`, `2w` or `1d`. - the parser does not support implicit record class, you have to explicitely set it to `IN`
kerem 2026-03-15 22:29:48 +03:00
Author
Owner

@bluejekyll commented on GitHub (Dec 15, 2017):

the parser does not support the specifiying times with letters such as 6h, 2w or 1d

This one surprises me, because I know I added support for it, we should add a test case for that specifically:

https://github.com/bluejekyll/trust-dns/blob/master/client/src/serialize/txt/master.rs#L385-L423

Edit: after reviewing the code, I realize what the problem is, it's specifically in the SOA record that this support wasn't added, we need call back the method I linked above:

https://github.com/bluejekyll/trust-dns/blob/master/client/src/serialize/txt/rdata_parsers/soa.rs#L46-L72

the parser does not support implicit record class, you have to explicitely set it to IN

We can default to IN, I don't have a problem with that. It's been a while since I looked at this code, but I think the default is set to the last Record seen, so it should be as simple as setting this to Some(DNSClass::IN) instead of None:

https://github.com/bluejekyll/trust-dns/blob/master/client/src/serialize/txt/master.rs#L150

<!-- gh-comment-id:352136020 --> @bluejekyll commented on GitHub (Dec 15, 2017): > the parser does not support the specifiying times with letters such as 6h, 2w or 1d This one surprises me, because I know I added support for it, we should add a test case for that specifically: https://github.com/bluejekyll/trust-dns/blob/master/client/src/serialize/txt/master.rs#L385-L423 Edit: after reviewing the code, I realize what the problem is, it's specifically in the SOA record that this support wasn't added, we need call back the method I linked above: https://github.com/bluejekyll/trust-dns/blob/master/client/src/serialize/txt/rdata_parsers/soa.rs#L46-L72 > the parser does not support implicit record class, you have to explicitely set it to IN We can default to IN, I don't have a problem with that. It's been a while since I looked at this code, but I think the default is set to the last Record seen, so it should be as simple as setting this to `Some(DNSClass::IN)` instead of `None`: https://github.com/bluejekyll/trust-dns/blob/master/client/src/serialize/txt/master.rs#L150
Author
Owner

@davepacheco commented on GitHub (Mar 2, 2022):

In case it's helpful to anyone else, the error message I saw was:

Error { kind: ParseInt(ParseIntError { kind: InvalidDigit }) }', bin/src/named.rs:405:27

This issue helped me find the problem (using times like "1h" in the SOA record) and work around it. Thanks!

<!-- gh-comment-id:1057438972 --> @davepacheco commented on GitHub (Mar 2, 2022): In case it's helpful to anyone else, the error message I saw was: ``` Error { kind: ParseInt(ParseIntError { kind: InvalidDigit }) }', bin/src/named.rs:405:27 ``` This issue helped me find the problem (using times like "1h" in the SOA record) and work around it. Thanks!
Author
Owner

@bluejekyll commented on GitHub (Mar 3, 2022):

Which version of trust-dns did you experience this with @davepacheco?

<!-- gh-comment-id:1058243528 --> @bluejekyll commented on GitHub (Mar 3, 2022): Which version of trust-dns did you experience this with @davepacheco?
Author
Owner

@davepacheco commented on GitHub (Mar 3, 2022):

I cloned the default branch and built it yesterday. I was on commit 8515a4321f.

<!-- gh-comment-id:1058314163 --> @davepacheco commented on GitHub (Mar 3, 2022): I cloned the default branch and built it yesterday. I was on commit 8515a4321f796aaccc84ed1c3954e3f302941d9f.
Author
Owner

@bluejekyll commented on GitHub (Mar 3, 2022):

And was the lack of IN on the records the issue that triggered this for you?

<!-- gh-comment-id:1058369608 --> @bluejekyll commented on GitHub (Mar 3, 2022): And was the lack of `IN` on the records the issue that triggered this for you?
Author
Owner

@bluejekyll commented on GitHub (Mar 3, 2022):

i.e. if we use the above config as a reference, would that cover your use case as well?

<!-- gh-comment-id:1058371418 --> @bluejekyll commented on GitHub (Mar 3, 2022): i.e. if we use the above config as a reference, would that cover your use case as well?
Author
Owner

@davepacheco commented on GitHub (Mar 3, 2022):

It appeared to be the use of human-readable times (like "1h") that did it. When I changed all of those to an integer number of seconds, it worked. When I changed any of them back, I got that error.

(edit: sorry for the ambiguity earlier -- I see there were two issues described here and I zero'd in on the one I hit, related to human-readable time strings)

<!-- gh-comment-id:1058529544 --> @davepacheco commented on GitHub (Mar 3, 2022): It appeared to be the use of human-readable times (like "1h") that did it. When I changed all of those to an integer number of seconds, it worked. When I changed any of them back, I got that error. (edit: sorry for the ambiguity earlier -- I see there were two issues described here and I zero'd in on the one I hit, related to human-readable time strings)
Author
Owner

@bluejekyll commented on GitHub (Mar 3, 2022):

Ok. And in the SOA record specifically it sounds like? I’ll get that fixed.

<!-- gh-comment-id:1058550003 --> @bluejekyll commented on GitHub (Mar 3, 2022): Ok. And in the SOA record specifically it sounds like? I’ll get that fixed.
Author
Owner

@davepacheco commented on GitHub (Mar 4, 2022):

Yup, it was in the SOA record.

<!-- gh-comment-id:1059528802 --> @davepacheco commented on GitHub (Mar 4, 2022): Yup, it was in the SOA record.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#440
No description provided.