Skip to content
This repository was archived by the owner on May 16, 2024. It is now read-only.

Commit 6c882b8

Browse files
committed
fix(PIN pad): ignore ScardControl errors when reading card reader features
1 parent fbaf440 commit 6c882b8

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/SmartCard.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,22 @@ class CardImpl
7979
cardHandle(cardParams.first), _protocol({cardParams.second, sizeof(SCARD_IO_REQUEST)})
8080
{
8181
// TODO: debug("Protocol: " + to_string(protocol()));
82-
DWORD size = 0;
83-
BYTE feature[256];
84-
SCard(Control, cardHandle, DWORD(CM_IOCTL_GET_FEATURE_REQUEST), nullptr, 0u, feature,
85-
DWORD(sizeof(feature)), &size);
86-
for (unsigned char* p = feature; DWORD(p - feature) < size;) {
87-
unsigned int tag = *p++;
88-
unsigned int len = *p++;
89-
unsigned int value = 0;
90-
for (unsigned int i = 0; i < len; ++i)
91-
value |= *p++ << 8 * i;
92-
features[DRIVER_FEATURES(tag)] = ntohl(value);
82+
try {
83+
DWORD size = 0;
84+
BYTE feature[256];
85+
SCard(Control, cardHandle, DWORD(CM_IOCTL_GET_FEATURE_REQUEST), nullptr, 0u, feature,
86+
DWORD(sizeof(feature)), &size);
87+
for (unsigned char* p = feature; DWORD(p - feature) < size;) {
88+
unsigned int tag = *p++;
89+
unsigned int len = *p++;
90+
unsigned int value = 0;
91+
for (unsigned int i = 0; i < len; ++i)
92+
value |= *p++ << 8 * i;
93+
features[DRIVER_FEATURES(tag)] = ntohl(value);
94+
}
95+
} catch (const ScardError&) {
96+
// Ignore driver errors during card feature requests.
97+
// TODO: debug(error)
9398
}
9499
}
95100

0 commit comments

Comments
 (0)