diff --git a/YubiKit/YubiKit/Connections/NFCConnection/YKFNFCConnectionController.m b/YubiKit/YubiKit/Connections/NFCConnection/YKFNFCConnectionController.m index 823ab9bd..e5a667d6 100644 --- a/YubiKit/YubiKit/Connections/NFCConnection/YKFNFCConnectionController.m +++ b/YubiKit/YubiKit/Connections/NFCConnection/YKFNFCConnectionController.m @@ -100,7 +100,9 @@ - (void)execute:(nonnull YKFAPDU *)command timeout:(NSTimeInterval)timeout compl }]; // Lock the async call to enforce the sequential execution using the library dispatch queue. - dispatch_semaphore_wait(executionSemaphore, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(timeout * NSEC_PER_SEC))); + if(dispatch_semaphore_wait(executionSemaphore, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(timeout * NSEC_PER_SEC))) != 0) { + executionError = [YKFSessionError errorWithCode:YKFSessionErrorReadTimeoutCode]; + } // Do not notify if the operation was canceled. if (operation.isCancelled) { diff --git a/YubiKit/YubiKit/Connections/SmartCardConnection/YKFSmartCardConnectionController.m b/YubiKit/YubiKit/Connections/SmartCardConnection/YKFSmartCardConnectionController.m index e2aed4cb..4ff43c91 100644 --- a/YubiKit/YubiKit/Connections/SmartCardConnection/YKFSmartCardConnectionController.m +++ b/YubiKit/YubiKit/Connections/SmartCardConnection/YKFSmartCardConnectionController.m @@ -131,7 +131,9 @@ - (void)execute:(nonnull YKFAPDU *)command timeout:(NSTimeInterval)timeout compl }]; // Lock the async call to enforce the sequential execution using the library dispatch queue. - dispatch_semaphore_wait(executionSemaphore, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(timeout * NSEC_PER_SEC))); + if(dispatch_semaphore_wait(executionSemaphore, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(timeout * NSEC_PER_SEC))) != 0) { + executionError = [YKFSessionError errorWithCode:YKFSessionErrorReadTimeoutCode]; + } // Do not notify if the operation was canceled. if (operation.isCancelled) {