aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2013-01-11 02:18:39 +0000
committerNIIBE Yutaka <[email protected]>2013-01-11 02:18:39 +0000
commit4dddf32c83f52483d95d7770232e9e808558e702 (patch)
treefaca2525cdb44af4f99e03716203f2b7627f1e3b
parentSCD: Support not-so-smart card readers. (diff)
downloadgnupg-4dddf32c83f52483d95d7770232e9e808558e702.tar.gz
gnupg-4dddf32c83f52483d95d7770232e9e808558e702.zip
SCD: Hold lock for pinpad input.
* scd/apdu.c (apdu_check_keypad, apdu_keypad_verify) (apdu_keypad_modify): Hold lock to serialize communication.
-rw-r--r--scd/apdu.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/scd/apdu.c b/scd/apdu.c
index 68d4e9970..278e08a36 100644
--- a/scd/apdu.c
+++ b/scd/apdu.c
@@ -3429,9 +3429,18 @@ apdu_check_keypad (int slot, int command, int pin_mode,
return SW_HOST_NO_DRIVER;
if (reader_table[slot].check_keypad)
- return reader_table[slot].check_keypad (slot, command,
+ {
+ int sw;
+
+ if ((sw = lock_slot (slot)))
+ return sw;
+
+ sw = reader_table[slot].check_keypad (slot, command,
pin_mode, pinlen_min, pinlen_max,
pin_padlen);
+ unlock_slot (slot);
+ return sw;
+ }
else
return SW_HOST_NOT_SUPPORTED;
}
@@ -3452,8 +3461,17 @@ apdu_keypad_verify (int slot, int class, int ins, int p0, int p1, int pin_mode,
return SW_HOST_NO_DRIVER;
if (reader_table[slot].keypad_verify)
- return reader_table[slot].keypad_verify (slot, class, ins, p0, p1,
+ {
+ int sw;
+
+ if ((sw = lock_slot (slot)))
+ return sw;
+
+ sw = reader_table[slot].keypad_verify (slot, class, ins, p0, p1,
&pininfo);
+ unlock_slot (slot);
+ return sw;
+ }
else
return SW_HOST_NOT_SUPPORTED;
}
@@ -3474,8 +3492,17 @@ apdu_keypad_modify (int slot, int class, int ins, int p0, int p1, int pin_mode,
return SW_HOST_NO_DRIVER;
if (reader_table[slot].keypad_modify)
- return reader_table[slot].keypad_modify (slot, class, ins, p0, p1,
+ {
+ int sw;
+
+ if ((sw = lock_slot (slot)))
+ return sw;
+
+ sw = reader_table[slot].keypad_modify (slot, class, ins, p0, p1,
&pininfo);
+ unlock_slot (slot);
+ return sw;
+ }
else
return SW_HOST_NOT_SUPPORTED;
}