-
Notifications
You must be signed in to change notification settings - Fork 220
Proposed fix for crash in calculateFirmwareRanges() due to division by zero #443
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
Conversation
…y zero If the maxSize UInt32 is zero, the internal division inside calculateFirmwareRanges() will crash both the framework and the caller app.
Attached crash report sourced from nRF Connect for iOS 2.4.12:
|
I thought about fixing this crash in multiple ways, like changing the specific division and inserting a min(maxLen, 1) into it to ensure this doesn't happen again. However, if maxLength returned from the Device is zero, it means no Data is supported in return, so I don't consider the DFU Process can continue and it's worse to keep the code going as usual. I'm open to fix this in any other way that @philips77 or anyone else considers to be better overall. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The maxSize
parameter is max size of an object. The message may say: Received invalid max size = 0.
Although, I think the issue comes from a fact that the device disconnects, or the value is somehow overwritten and the value gets 0ed. Either way, reporting an error here seems the right thing to do.
…vide-by-zero-fix Improved fix for crash fixed in #443
If the maxSize UInt32 is zero, the internal division inside calculateFirmwareRanges() will crash both the framework and the caller app.