Skip to content

Commit

Permalink
Fixed Integer overflow crash
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Sep 6, 2018
1 parent 7876d31 commit fec0a38
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/GATTClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,9 @@ public final class GATTClient {
guard lastEnd >= operation.start
else { operation.completion(.error(Error.invalidResponse(pdu))); return }

guard lastEnd < .max // End of database
else { operation.success(); return }

operation.start = lastEnd + 1

if lastEnd < operation.end {
Expand Down Expand Up @@ -743,6 +746,9 @@ public final class GATTClient {
// get more if possible
let lastEnd = pdu.handlesInformationList.last?.groupEnd ?? 0x00

guard lastEnd < .max // End of database
else { operation.success(); return }

operation.start = lastEnd + 1

// need to continue scanning
Expand Down Expand Up @@ -812,6 +818,9 @@ public final class GATTClient {
guard lastHandle >= operation.start
else { operation.completion(.error(Error.invalidResponse(pdu))); return }

guard lastHandle < .max // End of database
else { operation.success(); return }

let start = lastHandle + 1

// need to continue discovery
Expand Down

0 comments on commit fec0a38

Please sign in to comment.