Mailing List Archive

Error in 2.3 regarding reader-port (infinite loop)
Hey everyone,
I just updated my Windows PC to 2.3. I used the "reader-port" option in
scdaemon.conf to only use my Yubikey. Since updating I have found that with
that option set, the scdaemon goes into an infinite loop when trying to
access smart cards (for example Kleopatra hangs while opening). If I remove
the reader-port option in the config, the loop stops. Looking at the logs,
it seems like scd is constantly trying to initiate the first reader it
finds)
I have attached logs of the wrong and correct behavior I observed
(debug-level guru, debug-all).

Best,
Anze Jensterle
Re: Error in 2.3 regarding reader-port (infinite loop) [ In reply to ]
On Wed, 29 Dec 2021 14:55, Anze Jensterle said:

> I just updated my Windows PC to 2.3. I used the "reader-port" option in

Do you mean gnupg 2.3.4 for Windows or the gpg4win 4.0 ?

> I have attached logs of the wrong and correct behavior I observed
> (debug-level guru, debug-all).

Thanks. We will try to replicate this.


Shalom-Salam,

Werner

--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.
Re: Error in 2.3 regarding reader-port (infinite loop) [ In reply to ]
> 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.
Re: Error in 2.3 regarding reader-port (infinite loop) [ In reply to ]
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@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.
>