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

PadToMinSize may break AddOption #23

Closed
remohammadi opened this issue Jul 24, 2016 · 2 comments
Closed

PadToMinSize may break AddOption #23

remohammadi opened this issue Jul 24, 2016 · 2 comments

Comments

@remohammadi
Copy link

AddOption expects that the packet is ended with END, but if the initial packet was smaller than 300 bytes, PadToMinSize is called and so the packet is padded and AddOption doesn't remove the END.

Can we postpone PadToMinSize until Serve?

@krolaw
Copy link
Owner

krolaw commented Jul 24, 2016

That would be a breaking change for those who run their own Serve, as one can currently expect that the message packets coming out of New and Reply to be valid messages ready to go.

One solution may be for AddOption to check for padding, and if it's there:
trim padding
defer PadToMinSize()
continue rest of function.

My question is however, is this a real problem? It appears to be only padded if you are calling New or Reply, which both expect you to pass your desired options upfront. AddOption is more about building the packet, not editing it (no DeleteOption for example). Perhaps the real solution is to improve the function comments.

Thoughts?

remohammadi added a commit to cafebazaar/blacksmith that referenced this issue Jul 25, 2016
@remohammadi
Copy link
Author

Thank you. We were modifying the packet on some condition. We fixed it by doing the changes on the options and then creating the packet and returning it without touching the result of ReplyPacket.

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