From 4dddf32c83f52483d95d7770232e9e808558e702 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 11 Jan 2013 11:18:39 +0900 Subject: [PATCH] SCD: Hold lock for pinpad input. * scd/apdu.c (apdu_check_keypad, apdu_keypad_verify) (apdu_keypad_modify): Hold lock to serialize communication. --- scd/apdu.c | 33 ++++++++++++++++++++++++++++++--- 1 file 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; }