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

ShortInput error while querying for A records #70

Closed
glts opened this issue Aug 19, 2020 · 7 comments
Closed

ShortInput error while querying for A records #70

glts opened this issue Aug 19, 2020 · 7 comments

Comments

@glts
Copy link
Contributor

glts commented Aug 19, 2020

The following program (adapted from the ‘sync’ example in domain-resolv) panics:

use domain::{
    base::{name::Dname, Rtype},
    rdata::AllRecordData,
};
use domain_resolv::StubResolver;
use std::str::FromStr;

fn main() {
    let name = Dname::<Vec<_>>::from_str("imsavscan.netvigator.com").unwrap();

    let res = StubResolver::run(move |stub| async move {
        stub.query((name, Rtype::A)).await
    });

    let res = res.unwrap();
    let res = res.answer().unwrap().limit_to::<AllRecordData<_, _>>();
    for record in res {
        let record = record.unwrap();
        println!("{}", record);
    }
}
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ShortInput', src/main.rs:18:22

It’s just a query for A records of domain imsavscan.netvigator.com.

It looks like the answer contains defective records? However, other DNS resolvers that I have tried do not indicate an error with this query, so I’m wondering if this could be a bug in domain-resolv? I could not investigate further, apologies for the simple bug report.

@partim
Copy link
Member

partim commented Aug 19, 2020

Curiously, it works on my machine. The response is fairly big, though. So there might be some truncation issues, perhaps caused by a NAT box along the way or some such. We do indeed currently not check for this case.

I will add a check for completeness of the message.

@partim
Copy link
Member

partim commented Aug 19, 2020

In the mean time, if you need a quick workaround, you could enable the use_vc option for the stub resolver config. This should force TCP and avoid truncation.

@glts
Copy link
Contributor Author

glts commented Aug 19, 2020

Thank you, that works. (I can reproduce this both on my machine at home and on a virtual private server in a data centre somewhere, by the way.)

@partim
Copy link
Member

partim commented Aug 20, 2020

Would you perchance be able to run dig +ignore +bufsize=1472 imsavscan.netvigator.com on an affected machine and paste the output (perhaps cutting out the answer section if it is just a bunch of A records)?

@partim
Copy link
Member

partim commented Aug 20, 2020

Scratch that. Can you try again with the udp-buffer-size branch?

I seem to have used a different UDP buffer size than I actually advertised.

@glts
Copy link
Contributor Author

glts commented Aug 20, 2020

On the branch I now see one more record line printed, and no panic. Great!

@partim
Copy link
Member

partim commented Aug 25, 2020

This has been fixed in #71.

@partim partim closed this as completed Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants