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

Fix off-by-one error when checking for last fragment #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mbbush
Copy link

@mbbush mbbush commented Oct 27, 2021

I discovered this bug when trying to update my inovelli LZW30 switches to firmware 1.22. The firmware updater worked fine for other firmware files, but not this one.

The reason is that there's a bug in the logic for checking for whether this is the last fragment, which falsely sets to true when this is the next-to-last fragment and the actual last fragment will only have 1 byte in it.

This only causes an actual problem when the firmware size is 1 more than a multiple of the fragment size, which is the case with the LZW30 firmware version 1.22 (93601 bytes).

Once I applied this change locally, I was able to successfully update my switches. I successfully flashed multiple firmware files with a variety of sizes, resulting in last-fragment sizes of 40 bytes, 1 byte, and something in between.

For more context, see https://community.inovelli.com/t/unable-to-update-black-switch-firmware-using-hubitat/9413/2

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 this pull request may close these issues.

1 participant