-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fix Unparsed::encoded_len
implementation
#66
Conversation
`Unparsed` contains raw bytes and as such the length is already stored inside and doesn't require any additional wrapping. Additionally fix the `Extension::encoded_len` implementation to use `Unparsed::encoded_len` instead of directly accessing the `Vec`. Co-authored-by: Ross Williams <[email protected]> Fixes: #64 Signed-off-by: Wiktor Kwapisiewicz <[email protected]>
Signed-off-by: Wiktor Kwapisiewicz <[email protected]>
Signed-off-by: Wiktor Kwapisiewicz <[email protected]>
I like your approach here better, since it contains the irregular length / untagged array behavior to the "oddball" I'll propose this myself if there's any way for me to push commits to this PR. |
Excellent point! I agree. I've sent you a collaborator invitation. Try accepting it and pushing here, I hope it will work :) |
Extension payload, after the RFC4251-encoded name string, is an opaque blob, not an RFC4251 array of bytes, so it MUST NOT have a u32 length header. This had been handled in the `<Extension as Encode>::encode` implementation, but that led to a bug in which there was a mismatch between the number of bytes written and the length calculated. This commit consolidates all the special-case handling of the opaque blob into `impl Encode for Unparsed`. Any messages (i.e. Extension) that contain `Unparsed` fields can now just call `encoded_len()` and `encode()` like for any other field type. Signed-off-by: Ross Williams <[email protected]>
7ab19da
to
88c8022
Compare
Previous commits mean that all usages of Unparsed should call `encoded_len()` and `encode()` directly, rather than access the internal `Vec<u8>`. Signed-off-by: Ross Williams <[email protected]>
I'm working on these test failures. I think |
Unlike an `Extension` message's `Unparsed` bytes, the `Unparsed` field of a `KeyConstraint::Extension` is tagged with its `u32` length. This commit fixes up `impl Encode for KeyConstraint` so that it calls `encoded_len_prefixed()` and `encode_prefixed()` to get the correct, length-tagged `bytes[]` on the wire. Signed-off-by: Ross Williams <[email protected]>
My initial guess about the failing tests was wrong. The "good" bytes in the tests are definitely spec-compliant and are the same structure that OpenSSH The problem is fixed by c50efaf, though. It was that the new
|
Edited my last comment, because that would be an API-breaking change that might hold back this PR until 0.5.0? @wiktor-k, what do you think? |
Hmm... I don't mind that change but if you want this fix in 0.4 series we need to create a branch from that tag and merge this fix there. It's not a big problem, just a bit of shuffling the commits around. Before I do that I'd like to be sure I do get you right though 😁 (If you want to you can create the branch yourself if I'm not mistaken) |
Haha. 😅 I didn't realize how much refactoring of the serialization there was between 0.4.0 and main. As I was investigating the backport, I remembered that my WIP project is already using the main branch anyway, because I'm depending on the I'll go ahead and push the commit to make |
In general I prefer smaller PRs but I don't want to break your flow here 😉 The separate module idea is also good. Please do that! I already got the feeling that we could split the existing files into several smaller modules so let's take the opportunity now. Thanks for the ideas and the implementation! 🙇♂️ |
Hm. I was thinking about how large a file |
Signed-off-by: Ross Williams <[email protected]>
Signed-off-by: Ross Williams <[email protected]>
Signed-off-by: Ross Williams <[email protected]>
Signed-off-by: Ross Williams <[email protected]>
All types are `pub use` in `mod proto`, so can be accessed at the same module path as before this change. Also exposed a `pub use crate::proto::Result` in `proto:message` to match the `type Result` alias that used to be there in order to avoid that paper cut of a breaking change. Also refactor tests into the modules that the test, except for a few left in `proto::message` that use `Request` and `Response` as entry points to test the parsing implementation in many submodules. Signed-off-by: Ross Williams <[email protected]>
…ssage Modularize `proto::messsage`
Okay, is there anything here to merge this too? 🤔 |
LGTM. If you want to go ahead and merge, I'll open another PR off |
Thank you! 🙇♂️ |
@wiktor-k Before I open a PR for moving the The tests under The static object initialization doesn't actually test any code, though, because it just uses the default Beyond |
Also, if you'd like to chat about any of these changes, what message platforms do you use? I'm |
Yup. Most of these tests logic would be handled by the round-trip and that's what I like :) The only thing that's not is that the deserializatuon produces good stuff in correct places. The test currently compare the entire structure which is okay but kind of complex (since, for example you need to have the key data). I think comparing just a couple of fields against static data (say That's what is not covered by round-trip and if one messes one field up these field by field comparisons will be easier to diagnose rather than "this vec of bytes is not equal to this vec of bytes". As for comms I'll ping you on Signal but it's problematic for two reasons: first, we're in different timezones and Signal is more sync than comments. Second: there are other contributors who like to see the reasoning for changes and it creates a paper trail of what happened and why. Phew 😅 thanks for digging into that. The new release will be really cool! 🤩 |
Supersedes #64