Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ximon18 opened this issue Dec 9, 2024 · 1 comment
Open
Assignees
Labels
bug Something isn't working unstable feature

Comments

@ximon18
Copy link
Member

ximon18 commented Dec 9, 2024

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 ximon18 changed the title Key::parse_from_bind() cannot parse a file that ends with an empty line. Key::parse_from_bind() cannot parse a file that ends with a line break. Dec 9, 2024
@bal-e
Copy link
Contributor

bal-e commented Dec 9, 2024

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.

@ximon18 ximon18 added the bug Something isn't working label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unstable feature
Projects
None yet
Development

No branches or pull requests

2 participants