domain icon indicating copy to clipboard operation
domain copied to clipboard

`Key::parse_from_bind()` cannot parse a file that ends with a line break.

Open ximon18 opened this issue 1 year ago • 1 comments

Given the following .key file Key::parse_from_bind() is able to parse it successfully:

example.org. IN DNSKEY 257 3 15 6VdB0mk5qwjHWNC5TTOw1uHTzA0m3Xadg7aYVbcRn8Y= ;{id = 38873 (ksk), size = 256b}

Change it by adding a line break at the end however and Key::parse_from_bind() fails with error ParseDnskeyTextError::Misformatted.

One can argue "but tools only generate valid files" so this isn't an issue but if it must be strict I would prefer a more useful error (I spent >10 minutes investigating this as I assumed some other part of the input was incorrect).

Yes I hit this issue because I didn't generate the file using a tool like ldns-keygen but instead copied a .key file content from test code into an actual file on disk and accidentally added a trailing line break while doing so, so one can attribute this to user error, but this poor user would appreciate a better error message...

ximon18 avatar Dec 09 '24 09:12 ximon18

That's definitely a bug, and I'll look into fixing it. More generally, I understand that we'd want some more helpful errors for end-users, but I want to be careful about how much information is safe to leak. I think a ParseDnskeyTextError::UnknownField would also be helpful.

bal-e avatar Dec 09 '24 10:12 bal-e