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

Improved fix for crash fixed in #443 #444

Merged
merged 2 commits into from
Jul 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,13 @@ internal class SecureDFUPeripheral : BaseCommonDFUPeripheral<SecureDFUExecutor,
func readDataObjectInfo() {
dfuService?.readDataObjectInfo(
onReponse: { response in
guard let maxSize = response.maxSize, maxSize > 0 else {
self.defaultErrorCallback(DFUError.unsupportedResponse,
"Received invalid maxSize (nil or smaller than 1).")
guard response.maxSize! > 0 else {
self.logger.e("Invalid Data Object Max size = 0 received (expected > 0, typically 4096 bytes)")
self.delegate?.error(.unsupportedResponse,
didOccurWithMessage: "Received max object size = 0, expected 4096")
return
}
self.delegate?.peripheralDidSendDataObjectInfo(maxLen: maxSize,
self.delegate?.peripheralDidSendDataObjectInfo(maxLen: response.maxSize!,
offset: response.offset!,
crc: response.crc!)
},
Expand All @@ -182,6 +183,12 @@ internal class SecureDFUPeripheral : BaseCommonDFUPeripheral<SecureDFUExecutor,
func readCommandObjectInfo() {
dfuService?.readCommandObjectInfo(
onReponse: { response in
guard response.maxSize! > 0 else {
self.logger.e("Invalid Command Object Max size = 0 received (expected > 0, typically 256 bytes)")
self.delegate?.error(.unsupportedResponse,
didOccurWithMessage: "Received max object size = 0, expected 256")
return
}
self.delegate?.peripheralDidSendCommandObjectInfo(maxLen: response.maxSize!,
offset: response.offset!,
crc: response.crc!)
Expand Down