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

Wrong name.encodingLength() for "" and "example.com." -> extra, trailing byte #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jablko
Copy link

@jablko jablko commented May 14, 2019

name.encodingLength() returns the wrong length (off by one) for "" (empty string) and "example.com." (absolute, ends in a dot) whereas name.encode() correctly handles both. Is this by design?

name.encodingLength() handles "example.com" (doesn't end in a dot) but not "", and "." (dot) but not "example.com.". name.encode() handles all four cases. The upshot is that answer.encode({ name: "", type: "A", data: "1.2.3.4" }) returns one extra, trailing byte. I've only ever observed it return a zero byte, but I guess it could be anything, because it uses Buffer.allocUnsafe()?

This simple commit just adds "" to the cases that name.encodingLength() supports. I'm happy to fix the "example.com." case in the same commit, if I'm on the right track?

@jablko jablko changed the title Wrong name.encodingLength() for "" and "example.com." -> extra, trailing byte Wrong name.encodingLength() for "" and "example.com." -> extra, trailing byte May 14, 2019
@thenewwazoo
Copy link

I think this might be related to the extra trailing byte I'm seeing in mafintosh/multicast-dns#13

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

Successfully merging this pull request may close these issues.

None yet

2 participants