-
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 non trailing zero message #12
base: master
Are you sure you want to change the base?
Conversation
Hey there! I've been playing with this parser myself and I had a question about the truncation that happens here. From the MavLink V2 documentation:
From my understanding of that, couldn't we say that once we work our way through the payload, any remaining fields are simply 0? |
Yep, i didn't realise that whole fields would be truncated. This PR fixes this issue. I could add a test with multiple null fields, but i think it should already work with the |
Oh, good point, hadn't considered truncation in the middle of a larger-than-1-byte field! Thanks for explaining that. I don't want to conflict with your PR, but would love to contribute, so I'm just going to send it to you directly and see what you think. I removed the If I'm wrong, feel free to throw it out haha, appreciate the guidance as I'm learning this protocol! Code in my branch locally at this point: |
You are absolutely right, thanks 👍 |
This PR fixes a bug if the last field in the message is zero.
The field will get truncated and
payload.readUInt8(start)
will throw a range error.This check
start >= payload.length
fixes the bug.