Skip to content

Commit

Permalink
Address report decryption failure seemoo-lab#239
Browse files Browse the repository at this point in the history
  • Loading branch information
FauconSpartiate committed May 23, 2024
1 parent a7f7eae commit 18db73b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion OpenHaystack/OpenHaystack/FindMy/FindMyController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ class FindMyController: ObservableObject {

let accessQueue = DispatchQueue(label: "threadSafeAccess", qos: .userInitiated, attributes: .concurrent, autoreleaseFrequency: .workItem, target: nil)
var decryptedReports = [FindMyLocationReport](repeating: FindMyLocationReport(lat: 0, lng: 0, acc: 0, dP: Date(), t: Date(), c: 0), count: reports.count)
var failedDecryptIndexes = [Int]()
DispatchQueue.concurrentPerform(iterations: reports.count) { (reportIdx) in
let report = reports[reportIdx]
guard let key = keyMap[report.id] else { return }
Expand All @@ -215,11 +216,16 @@ class FindMyController: ObservableObject {
decryptedReports[reportIdx] = locationReport
}
} catch {
return
accessQueue.async(flags: .barrier) {
failedDecryptIndexes.append(reportIdx)
}
}
}

accessQueue.sync {
for index in failedDecryptIndexes.sorted(by: { $0 > $1 }) {
decryptedReports.remove(at: index)
}
devices[deviceIdx].decryptedReports = decryptedReports
}
}
Expand Down

0 comments on commit 18db73b

Please sign in to comment.