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

minQuestionSize problem in padding #24

Closed
zoli opened this issue Jan 10, 2024 · 2 comments · Fixed by #25
Closed

minQuestionSize problem in padding #24

zoli opened this issue Jan 10, 2024 · 2 comments · Fixed by #25

Comments

@zoli
Copy link
Contributor

zoli commented Jan 10, 2024

From what I understand this line in pad function isn't right.

// get closest divisible by 64 to <packet-len> + 1 byte for 0x80
minQuestionSize := (len(packet)+1+63)/64 + 64

It doesn't result in closes divisible by 64. For example if packet length is 56 it will result in 65 which should be 64 (the closest divisible by 64 to 56+1 is 64).
I think it should get rewritten to STH like this:

minQuestionSize := len(packet) + 1 + (64 - (len(packet)+1)%64)
@ameshkov
Copy link
Owner

Would you like to submit a pull request? If you do, please also add a unit-test for this case.

@zoli
Copy link
Contributor Author

zoli commented Jan 11, 2024

Would you like to submit a pull request? If you do, please also add a unit-test for this case.

Sure. Will add unit tests too.

zoli added a commit to zoli/dnscrypt that referenced this issue Jan 11, 2024
fix problem with calculating closest divisible by 64
closes ameshkov#24
ameshkov pushed a commit that referenced this issue Mar 15, 2024
fix problem with calculating closest divisible by 64
closes #24
SamTherapy pushed a commit to SamTherapy/dnscrypt that referenced this issue Apr 17, 2024
fix problem with calculating closest divisible by 64
closes ameshkov#24
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 a pull request may close this issue.

2 participants