-
Notifications
You must be signed in to change notification settings - Fork 13
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 wrong chunk length #25
Conversation
In some rare cases there is a small subsequent frame which is not read and transceive aborts with wrong chunk length Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
I'm not sure it this really fixes it. But this PR introduces a possible new problem: imagine only one byte of a chunk is transferred, and then a newline. Since decoded.len() is usize, this would underflow and the read would terminate. But should be easy to fix. And could you post the transferred data with the Go mcumgr program in debug mode, in a gist, which demonstrates your original problem? Then it is easier for me to check it. |
I am not sure if thats a problem.
I don't have the same image anymore but go client
Unmodified mcumgr-client
Modified mcumgr-client
|
Thanks, you are right, the panic should be safe, wouldn't happen with valid data anyway. You patch is right, the length of the decoded data needs to be added (so -2 of your patch reads the 2 more bytes). I guess it worked so far only by change, because the base 64 decoding failed before, because it didn't use general_purpose::NO_PAD, pretty tricky. |
In some rare cases there is a small subsequent frame which is not read and transceive aborts with
wrong chunk length
I have mcuboot (zephyr) with the option
CONFIG_SINGLE_APPLICATION_SLOT=y
and use the serial recovery mode. There is an image on the controller with the version3.7.99.782043700
. I wanted to get the list of images and it failed withwrong chunk length
To be honest I don't completely understand the code. I just saw that there is only the first frame read and the second not. Here
mcumgr-client/src/transfer.rs
Line 171 in 3d910e0
mcumgr-client/src/transfer.rs
Line 160 in 3d910e0
I subtracted this 2 bytes too and it works now. I tested list, upload and reset with the fix and had no issues.