[Pcsclite-muscle] SCardBeginTransaction behavior under sharing violation

Ludovic Rousseau ludovic.rousseau at gmail.com
Mon Oct 16 12:35:34 PDT 2023


Le ven. 6 oct. 2023 à 21:11, Maksim Ivanov <emaxx at google.com> a écrit :
> Hello,

Hello Maksim,

Sorry for the delay. Your email was in the gmail spam folder. Funny
for a email from @google.com

> SCardBeginTransaction() is documented as "there will be no action
> taken" in case the reader is already locked. Also the
> SCARD_E_SHARING_VIOLATION error code is documented to be returned in
> case "someone else has exclusive rights".

Exact
Documentation at
https://pcsclite.apdu.fr/api/group__API.html#gaddb835dce01a0da1d6ca02d33ee7d861
is/was incorrect.

> However, judging from the implementation, it seems that the
> SCardBeginTransaction enters a poll loop, waiting for particular
> results from the daemon. If I'm reading it correctly, the loop doesn't
> exit as long as SCARD_E_SHARING_VIOLATION is received from the daemon
> (https://github.com/LudovicRousseau/PCSC/blob/52670e567267baf3579581f32ef3756a3644b9f2/src/winscard_clnt.c#L1193),
> meaning that the function would never return this code to the caller.
>
> If so, is this an oversight in the documentation, or rather in the
> implementation?

>From SCardBeginTransaction MSDN
https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardbegintransaction
" The function waits for the completion of all other transactions
before it begins. ".
So blocking is the expected behaviour.

I fixed the documentation in
https://github.com/LudovicRousseau/PCSC/commit/14fae208e37b991efdcc858e34af3b8c57809ddb

Thanks

--
 Dr. Ludovic Rousseau



More information about the pcsclite-muscle mailing list