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

Message pack and unpack fails with an empty name in a RR header #1517

Open
qdm12 opened this issue Nov 26, 2023 · 2 comments
Open

Message pack and unpack fails with an empty name in a RR header #1517

qdm12 opened this issue Nov 26, 2023 · 2 comments
Assignees

Comments

@qdm12
Copy link

qdm12 commented Nov 26, 2023

I lost quite a few hours fighting this off, so I thought I would voice this concern over here 😉
TLDR is packing a message with an empty string as its RR header name works, but unpacking it will fail with the rather obscure message dns: overflowing header size.

I wrote a little test to show the problem:

func Test_MessagePackUnpack(t *testing.T) {
	response := &dns.Msg{
		Answer: []dns.RR{
			&dns.A{
				Hdr: dns.RR_Header{
					Name: "",
				},
				A: net.IPv4(1, 2, 3, 4),
			},
		},
	}

	b, err := response.Pack()
	if err != nil { // no error
		t.Fatal(err)
	}

	decoded := new(dns.Msg)
	err = decoded.Unpack(b)
	if err != nil { // dns: overflowing header size
		t.Fatal(err)
	}
}

The reason behind this is likely from commit fdcdc6d which I'm not too sure why it is there, but assuming there is a reason for it, I feel like the Unpack method should work with empty name strings? If not, at least return a more explicit error stating the RR header name cannot be empty??

Thanks!

@miekg
Copy link
Owner

miekg commented Jan 15, 2024

some symmetry here would be nice

@miekg miekg self-assigned this Mar 29, 2024
@endreszabo
Copy link

I also encountered this, and I use the root label, e.g. dns.RR_Header{Name: "."} and it just works back and forth nicely.

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

3 participants