Pinpad input problem for GemPC Pinpad reader

NIIBE Yutaka gniibe at fsij.org
Mon Feb 4 02:23:56 CET 2013


I applied and pushed this change to STABLE-BRANCH-2-0. 

On 2013-01-11 at 11:43 +0900, NIIBE Yutaka wrote:
> On 2013-01-10 at 17:15 +0900, NIIBE Yutaka wrote:
> > It seems that GemPC Pinpad reader is single threaded.
> > 
> > I need to configure SCDaemon with debug-disable-ticker option to
> > use the reader reliably (or I need to input quickly).
> > 
> > Here is a log when I don't configure debug-disable-ticker option.
> > 
> > When we were in use of pinpad, apdu_get_status got timeout (after 5
> > seconds, the timeout value of bulk_out).  See usb_bulk_write
> > failed: -110.
> 
> This is due to a bug which doesn't hold lock for _keypad functions.
> 
> Here is a patch to fix this (against master).  Same should be applied
> to 2.0.
> 
> OK to commit?
> 
> diff --git a/scd/apdu.c b/scd/apdu.c
> index 68d4e99..278e08a 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;
>  }

-- 





More information about the Gnupg-devel mailing list