Skip to content

Commit

Permalink
IFDHSetProtocolParameters: get convention before using it
Browse files Browse the repository at this point in the history
In case the reader defines CCID_CLASS_AUTO_PPS_PROP i.e. 25% or readers
according to https://ccid.apdu.fr/select_readers/?dwFeatures=6 AND the
card ATR declares ATR_CONVENTION_INVERSE i.e. 6% of cards according to
https://ludovicrousseau.blogspot.com/2016/02/atr-statistics-ts-initial-character.html
then the parameters settings were wrong.

Thanks to Coverity for the bug report:
CID 1503362 (#2 of 2): Uninitialized scalar variable (UNINIT)15.
uninit_use: Using uninitialized value convention.
  • Loading branch information
LudovicRousseau committed Apr 3, 2022
1 parent 7bca22e commit 0b33473
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ifdhandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,16 +980,16 @@ EXTERNAL RESPONSECODE IFDHSetProtocolParameters(DWORD Lun, DWORD Protocol,
}
}

/* Now we must set the reader parameters */
if (ATR_MALFORMED == ATR_GetConvention(&atr, &convention))
return IFD_COMMUNICATION_ERROR;

/* specific mode and implicit parameters? (b5 of TA2) */
if (atr.ib[1][ATR_INTERFACE_BYTE_TA].present
&& (atr.ib[1][ATR_INTERFACE_BYTE_TA].value & 0x10))
return IFD_COMMUNICATION_ERROR;

end:
/* Now we must set the reader parameters */
if (ATR_MALFORMED == ATR_GetConvention(&atr, &convention))
return IFD_COMMUNICATION_ERROR;

/* T=1 */
if (SCARD_PROTOCOL_T1 == Protocol)
{
Expand Down

0 comments on commit 0b33473

Please sign in to comment.