Skip to content

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

Open
mbbush wants to merge 2 commits into
djdizzyd:masterfrom
mbbush:master
Open

Fix off-by-one error when checking for last fragment#18
mbbush wants to merge 2 commits into
djdizzyd:masterfrom
mbbush:master

Conversation

@mbbush
Copy link
Copy Markdown

@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