Skip to content

Builder generates invalide packets #49

Description

@fabiensanglard

I have a minium reproducible example where the Builder fails to generate correct packets.

use dns_parser::{Builder, Packet, QueryClass, QueryType};

fn main() {
    let mut builder = Builder::new_query(0, false);
    builder.add_question(
        "_adb-tls-connect._tcp.local.",
        false,
        QueryType::All,
        QueryClass::Any,
    );
    let query = builder.build();
    
    match query {
        Ok(buf) => {
            println!("DNS query: {:?}", buf);
            let Ok(packet) = Packet::parse(&buf) else {
                println!("Failed to parse DNS packet");
                return;
            };

            println!("Parsed packet {:#?}", packet);

        },
        Err(error) => println!("Error: {:?}", error),
    }
}

Running this example leads to Failed to parse DNS packet. It seems the issue is the trailing dot (in local.). I am not sure if this is legal or not but the lib should probably warn the user they are doing something wrong when building the packet if this is the case.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions