From 22309b2319ce79519a186caee0501b085d9a2424 Mon Sep 17 00:00:00 2001 From: Ben Toews Date: Tue, 27 Jun 2017 22:01:37 -0600 Subject: [PATCH 1/2] janky "mutex" to avoid race between read/write of UserPresence.current fixes mastahyeti/SoftU2F#1 --- SoftU2FTool/UserPresence.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/SoftU2FTool/UserPresence.swift b/SoftU2FTool/UserPresence.swift index ad43493..cc2637c 100644 --- a/SoftU2FTool/UserPresence.swift +++ b/SoftU2FTool/UserPresence.swift @@ -17,9 +17,25 @@ class UserPresence: NSObject { typealias Callback = (_ success: Bool) -> Void - static var current: UserPresence? static var skip = false + // Hacks to avoid a race between reads/writes to current. + static let currentAccessQueue = DispatchQueue(label: "currentAccessQueue") + static var _current: UserPresence? + static var current: UserPresence? { + get { + return currentAccessQueue.sync { + return _current + } + } + + set(newValue) { + currentAccessQueue.sync { + _current = newValue + } + } + } + // Display a notification, wait for the user to click it, and call the callback with `true`. // Calls callback with `false` if another test is done while we're waiting for this one. static func test(_ type: Notification, with callback: @escaping Callback) { From e48dbe76671077b908a645625392755056613d97 Mon Sep 17 00:00:00 2001 From: Ben Toews Date: Wed, 5 Jul 2017 16:40:56 -0600 Subject: [PATCH 2/2] bump softu2f submodule with security fixes --- SoftU2F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SoftU2F b/SoftU2F index c70e796..8343a82 160000 --- a/SoftU2F +++ b/SoftU2F @@ -1 +1 @@ -Subproject commit c70e796dffc4d2a86052afa313f06eb14bbfc976 +Subproject commit 8343a82cd4fc057c873f8ade3d36e7f7fff863b8