Error in 2.3 regarding reader-port (infinite loop)

Anze Jensterle anze at anze.dev
Fri Dec 31 15:57:06 CET 2021


I made a PR to fix this: https://dev.gnupg.org/D547.

Best,
Anze

On Thu, Dec 30, 2021 at 3:52 PM Werner Koch <wk at gnupg.org> wrote:

> > I have attached logs of the wrong and correct behavior I observed
> > (debug-level guru, debug-all).
>
> Yes, this is an obvious bug.  We have not yet seen it because on Unix we
> prefer to use the CCID driver using a different code path and further
> with 2.3 there is not much need to specify a port.
>
> Here is the bug:
>
>       while (dl->idx < dl->idx_max)
>         {
>           const char *rdrname = pcsc.rdrname[dl->idx];
>
>           if (DBG_READER)
>             log_debug ("apdu_open_reader: %s\n", rdrname);
>
>           /* Check the identity of reader against already opened one.  */
>           for (slot = 0; slot < MAX_READER; slot++)
>             if (reader_table[slot].used
>                 && !strcmp (reader_table[slot].rdrname, rdrname))
>               break;
>
>           if (slot == MAX_READER)
>             { /* Found a new device.  */
>               if (DBG_READER)
>                 log_debug ("apdu_open_reader: new device=%s\n", rdrname);
>
>               /* When reader string is specified, check if it is the one.
> */
>               if (readerno < 0
>                   && strncmp (rdrname, dl->portstr, strlen (dl->portstr))
> != 0)
>                 continue;
>
> The /continue/ causes the loop because the loop index is not bumped.
>
>
> Salam-Shalom,
>
>    Werner
>
> --
> Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnupg-users/attachments/20211231/0b0a90a8/attachment.html>


More information about the Gnupg-users mailing list