diff --git a/src/libopensc/apdu.c b/src/libopensc/apdu.c index 663b7c1e..ebd09c5e 100644 --- a/src/libopensc/apdu.c +++ b/src/libopensc/apdu.c @@ -300,15 +300,15 @@ static int sc_check_apdu(sc_card_t *card, const sc_apdu_t *apdu) goto error; break; case SC_APDU_CASE_3_SHORT: + /* inconsistent datalen */ + if (apdu->datalen != apdu->lc) + goto error; /* data is send */ - if (apdu->datalen == 0 || apdu->data == NULL || apdu->lc == 0) + if (apdu->datalen != 0 && apdu->data == NULL) goto error; /* no data is expected */ if (apdu->le != 0) goto error; - /* inconsistent datalen */ - if (apdu->datalen != apdu->lc) - goto error; break; case SC_APDU_CASE_4_SHORT: /* data is send */