Skip to content

Commit

Permalink
iso7816: if index is beyond file, return EOF
Browse files Browse the repository at this point in the history
commands for data unit handling may return 6B00 if the specified index
is too large (ISO 7816-4). Maybe SC_ERROR_OFFSET_TOO_LARGE would be more
appropriate, but this is (1) currently not used only for internal errors
and (2) this error code is not currently handled by sc_read_binary.
Hence, we stick to SC_ERROR_FILE_END_REACHED.
  • Loading branch information
frankmorgner committed Mar 10, 2021
1 parent 8aec32a commit 1cc2b9e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libopensc/iso7816.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ iso7816_read_binary(struct sc_card *card, unsigned int idx, u8 *buf, size_t coun
LOG_TEST_RET(ctx, r, "APDU transmit failed");

r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r == SC_ERROR_FILE_END_REACHED)
if (r == SC_ERROR_FILE_END_REACHED
|| r == SC_ERROR_INCORRECT_PARAMETERS)
LOG_FUNC_RETURN(ctx, apdu.resplen);
LOG_TEST_RET(ctx, r, "Check SW error");

Expand Down

0 comments on commit 1cc2b9e

Please sign in to comment.