fix logic of send/recv sizes in config files

- they are not set if
  SCardControl(card_handle, CM_IOCTL_GET_FEATURE_REQUEST, ...
  fails
- regarding max_send_size the logic is inverted
This commit is contained in:
Andreas Kemnade 2018-11-07 16:13:45 +01:00 committed by Frank Morgner
parent c032b2f15d
commit eddea6f3c2
1 changed files with 9 additions and 8 deletions

View File

@ -1191,13 +1191,6 @@ static void detect_reader_features(sc_reader_t *reader, SCARDHANDLE card_handle)
}
}
/* max send/receive sizes: with default values only short APDU supported */
reader->max_send_size = priv->gpriv->force_max_send_size ?
priv->gpriv->force_max_send_size :
SC_READER_SHORT_APDU_MAX_SEND_SIZE;
reader->max_recv_size = priv->gpriv->force_max_recv_size ?
priv->gpriv->force_max_recv_size :
SC_READER_SHORT_APDU_MAX_RECV_SIZE;
if (priv->get_tlv_properties) {
/* Try to set reader max_send_size and max_recv_size based on
* detected max_data */
@ -1206,7 +1199,7 @@ static void detect_reader_features(sc_reader_t *reader, SCARDHANDLE card_handle)
if (max_data > 0) {
sc_log(ctx, "Reader supports transceiving %d bytes of data",
max_data);
if (priv->gpriv->force_max_send_size)
if (!priv->gpriv->force_max_send_size)
reader->max_send_size = max_data;
else
sc_log(ctx, "Sending is limited to %"SC_FORMAT_LEN_SIZE_T"u bytes of data"
@ -1276,6 +1269,14 @@ int pcsc_add_reader(sc_context_t *ctx,
goto err1;
}
/* max send/receive sizes: with default values only short APDU supported */
reader->max_send_size = priv->gpriv->force_max_send_size ?
priv->gpriv->force_max_send_size :
SC_READER_SHORT_APDU_MAX_SEND_SIZE;
reader->max_recv_size = priv->gpriv->force_max_recv_size ?
priv->gpriv->force_max_recv_size :
SC_READER_SHORT_APDU_MAX_RECV_SIZE;
ret = _sc_add_reader(ctx, reader);
if (ret == SC_SUCCESS) {